View Single Post
Old 01-10-2013, 05:11 AM   PM User | #1
juliushg
New Coder

 
Join Date: Jul 2012
Location: Mexico
Posts: 45
Thanks: 9
Thanked 0 Times in 0 Posts
juliushg is an unknown quantity at this point
Button id passing value to javascript

Is it possible to create a numeric id to asign to buttons (images) generated in a loop and pass that numeric id (the number part) to a function in javascript?

Something like this:

1st line:
Code:
<input id="q0" type="image" src="http://myurl/button-subtract.png" onclick="SubtractOne(0)"/> // (0) comes from q0
<input id="q0" type="image" src="http://myurl/button-subtract.png" onclick="AddOne(0)"/> // (0) comes from q0
2nd line:
Code:
<input id="q1" type="image" src="http://myurl/button-subtract.png" onclick="SubtractOne(1)"/> // (1) comes from q1
<input id="q1" type="image" src="http://myurl/button-subtract.png" onclick="AddOne(1)"/> // (1) comes from q1
And so on?
juliushg is offline   Reply With Quote