Robert Granlund
asked on
jQuery From Input Update
I have a form that I would like to change the value of an input by it's name. For some reason I'm having an issue with targeting the name:
<script>
$( 'input[name="item[0][total"]' ).val( damage_total );
</script>
<html>
<input type="text" value="296" name="item[0][total]">
</html>
You need to escape the array brackets:
$('input[name=item\\[0\\]\\[total\\]]' ).val( damage_total );
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
I guess just a simple typo - there was one closing bracket missing:
HTH
Rainer
I guess just a simple typo - there was one closing bracket missing:
$( 'input[name="item[0][total]"]' ).val( damage_total );
But you should reconsider to change your element names as I doubt that brackets are allowed characters.HTH
Rainer
Too late :-) By 16 seconds :-]
@Rainer - brackets are allowed in inputs and actually I'd strongly recommend them - they're an easy way to group form data - making the POST processing much simpler
Open in new window
I hope it is that simple.