I have an input field which looks something like this...
<input type='hidden' name='myInput[1][sausages][0][]' value='123' />
I need to change the value in the third set of square brackets when a user clicks on a button...
so something like
$("a.mylink").click( function() {
$(this).siblings('input[name*=myInput]')..... CHANGE THE 0 to 1 in the third set of square brackets...
});
Any ideas how I can do this?
Try This:
$('input').attr('name',$('input').attr('name').replace(/\[\d+](?!.*\[\d)/, '[1]'))