Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select input field with name as array field

I wanted to select the text field based on condition, for example:

if only text field name = sname[] than only put value in it.

For this I used

<input type="text" name="sname[]" />

where name = sname;

//For each name type field in extra add contact module if that i visible.
    $('input[name=' + name + '[]]').each(function() { 

});

But I'm not able to get inside of it. Please suggest how to get into the selection.

like image 720
Jos Avatar asked Feb 15 '11 05:02

Jos


1 Answers

$('input[name="' + name + '[]"]').each(function() {
    $(this).val('Some value');
});
like image 200
stealthyninja Avatar answered Oct 07 '22 00:10

stealthyninja