1
As described in the title, follow the example below:
---- HTML
<form id="nameGenderForm">
<table id="teste">
<tr>
<th >Name</th>
<th >Gender</th>
</tr>
<tr>
<td id="11"><input type="hidden" name="11" value=""></td>
<td id="12"><input type="hidden" name="12" value=""></td>
</tr>
<tr>
<td id="21"><input type="hidden" name="[21].value" value=""></td>
<td id="22"><input type="hidden" name="[22].value" value=""></td>
</tr>
</table>
<input type="submit" />
</form>
---- SCRIPT
$("#nameGenderForm").submit(function(event) {
event.preventDefault();
$("input[name=11]").val("AAAA")
$("input[name=22]").val("BBBB")
//$("input[name=[21].value]").val("FFFF") // aqui: como setar nesse caso?
//$("input[name=[22].value]").val("ZZZZZ")
rawData = $('#teste input:hidden').serializeArray();
var formData = JSON.stringify(rawData);
alert(formData);
});
For ease, I put in Jsfiddle https://jsfiddle.net/leandrotss/jf5dg98o/4/
What is your intention to use the brackets ?
– Lucas Fontes Gaspareto
I don’t know pq but partial view mounted table ssim. Maybe pq instead of using ienumerable or use ilist.
– Leandro
Soen: http://stackoverflow.com/questions/4608487/how-do-i-reference-an-element-by-name-with-brackets-in-it
– Lucas Fontes Gaspareto
ienumerable ? ilist? that would be something with C# ?
– Daniel Omine
Yes. I just need to figure out how to set/fetch that element
– Leandro