Reputation: 3974
I am trying to pass the value of a string to a textarea so it would be visible in the textarea. Looks like there is no attribute like 'value' in textarea.
Upvotes: 2
Views: 3167
Reputation: 3974
I tried the following code and it worked. I just entered the string within the textarea tags as follows: String value
<% String textAreaValue = session.getAttribute("textArea"); %>
<textarea rows = "4" cols = "20" name = "area" id = "area"><% if(condition) { %>
<%=textAreaValue %><%}%> </textarea>
Upvotes: 1
Reputation: 17839
you can also set its contents using JQuery by:
$("#id_of_textarea").val("here is your message");
or using javascript by:
document.getElementById("id_of_textarea").value = "here is your message";
Upvotes: 0
Reputation: 24124
The attribute on text area to set the content is textarea.innerText
for IE and textarea.textContent
for firefox.
Upvotes: 3
Reputation: 8511
The 'textarea' tag does have attribute 'value', see: http://www.w3schools.com/jsref/dom_obj_textarea.asp
In case you want to put the content in textarea to be a string gotten from server, you must call to the server to get the value by AJAX from your JavaScript code. A little guide: http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp
There are other advanced methods to do this with Java Applet, ActiveX,... but this is for advanced purposes only.
Upvotes: 4