I’m trying to set the value of three different input text fields with an onclick function.
I have an image that has this code…
<img src="images/delete_row.png" width="25" onClick="clearRow(0);" />
And I have three input text fields that all have the id of “0”.
When I click my image I want to set the value of all three fields to empty.
Can someone please help me write a function that can do this?
Thanks!
First, you need your
idvalues to be different. You should never have the same ID twice on the same page. So lets use this as the example HTML:You could use this JavaScript function:
And your
imgtag would remain unchanged: