0

In a page I have a number of text box with name in array format. I want to put a value 'test' in one of them when a function is executed or event is occured. But my jquery code puts value in all the textboxes. Also I cannot put ID to the textbox as its framework generated.

<input type="text" maxlength="255" name="School[school_name]">
<input type="text" maxlength="255" name="School[contact_person]">
<input type="text" maxlength="255" name="School[test]">




$('input:text[name=School[school_name]]').val('test');

Thanks Ab

0

3 Answers 3

1

Put quotes around the name:

$('input:text[name="School[school_name]"]').val('test');
Sign up to request clarification or add additional context in comments.

Comments

1

Here's a jsfiddle that shows how to do it: http://jsfiddle.net/2eYwQ/11/

Put the actual name in quotes.

Comments

0
$('input[name="School[school_name]"]').val('test');

​ Will do the magic for you. The syntax is: $('tag[attribute="value"]')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.