I am only setting one simple value in text area using jquery on radio button click. but it sets nothing.
My Code is:
Javascript
---------
$("input[name=radio_workitem]").on("change",function(){
$("input[name='workItemVO.note']",'#id_form_workitem_view').val("dummyNote");
}
<!-- language: lang-html -->
<input type="radio" name="radio_workitem" value="<s:property value="workItemId"/>">
<s:form id="id_form_workitem_view">
<s:textfield name="workItemVO.subject" id="id_txt_wi_subject" class="form-control" readonly="true" />
<s:textfield name="workItemVO.createdBy" class="form-control" readonly="true"/>
<s:textarea name="workItemVO.note" class="form-control" rows="4"></s:textarea>
$("input[name='workItemVO.note']",'#id_form_workitem_view').html("dummyNote");
$("input[name='workItemVO.note']",'#id_form_workitem_view').text("dummyNote")
Doesn't work.
Here: if I set value using text area id, it works properly example: $("#Note").val("dummyNote"); // works fine
But I want to use "Name" not "Id"
Plz help, i am very new in Stack overflow, may be some mistake in my description. Plz let me know.
Thanks in Advance
Answer: Use the jQuery val() Method You can simply use the val() method to set the value of a textarea dynamically using jQuery.
<textarea> does not support the value attribute.
The DOM Textarea defaultValue Property is used to set or return the default value of the textarea field. Syntax: It is used to return the defaultValue property.
input[name='workItemVO.note'] //this won't work because textArea is not an input
use textarea
instead of input
$("textarea[name='workItemVO.note']").val('dummyNote')
JSFIDDLE DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With