6

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> 

What I have Tried:

$("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

1

2 Answers 2

4
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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot !! More over for your quick reply.!! it worked for me.
1

<textarea/> is not an <input/>.

You can use the :input selector, or simply specify textarea[name="..."]

Your on change listener is missing a ) at the end, but I assume that's a copy and paste error.

Provided that <s:textarea/> does indeed render as a textarea with the name intact your code will work if you use the textarea selector.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.