Skip to content Skip to sidebar Skip to footer

Passing Dynamic Id's To Javascript

i have a while loop that changes the id of each input field. print'

Solution 1:

form.pro0.value;

is used to access input with name as pro0

Try form.productitemsupdate_0.value or

try using getElementByIdhttp://www.tizag.com/javascriptT/javascript-getelementbyid.php

Also change your php code to

print"<td><input style=\"text-align:center\" type=\"text\" name=\"productitemsupdate_$num\" value=\"$row[productitems]\" size=\"5\" id=\"pro$num\">}</td>";

Solution 2:

Use square bracket notation instead of dot notation.

foo.bar === foo['bar']

You can pass the string in a variable rather than as a literal.

Post a Comment for "Passing Dynamic Id's To Javascript"