I am cloning a table row using JQuery and, amongst other things, the row contains a hidden field. I want to change the value of the hidden field when I clone the row.
The form field:
<input type="hidden" name="items.Index" id="items.Index" value="0" />
The JQuery:
var id = document.getElementById("id").value;
var newId = parseInt(id) + 1;
var clonedRow = $("#myTable tr:last").clone();
$("#items.Index", clonedRow).attr({ "value": newId });
$("#myTable").append(clonedRow);
I ahve also tried $("#items.Index", clonedRow).val(newId);
in place of $("#items.Index", clonedRow).attr({ "value": newId });
I have other items in the table row which are being successfully manipulated but the value of this form field never changes.
Any ideas?