passing dynamic id's to javascript

后端 未结 2 1902
离开以前
离开以前 2021-01-16 11:17

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

   print\"

        
相关标签:
2条回答
  • 2021-01-16 11:34

    form.pro0.value;

    is used to access input with name as pro0

    Try form.productitemsupdate_0.value or

    try using getElementById http://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>";
    
    0 讨论(0)
  • 2021-01-16 11:41

    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.

    0 讨论(0)
提交回复
热议问题