Hi guys,
I have an array form input with an id: field[0], field[1] etc.
How can I set the value of each array element directly?
$(“#field[0]”).val(“value”) doesn’t appear to work.
Many thanks.
Hi guys,
I have an array form input with an id: field[0], field[1] etc.
How can I set the value of each array element directly?
$(“#field[0]”).val(“value”) doesn’t appear to work.
Many thanks.
Damn, wrong forum! Sorry about this mods. So used to posting problems on here, I forgot I to change to the correct forum.
$("#element_id_or_another_selector").eq(0).val("your value");
Great, thanks for the tip.
In my example’s case, I managed to get it to work by using the following:
$(“[id^=field]”).eq(index).val(newvalue);
Sorry mods again for posting to the wrong forum.