I'm trying to setup a few dynamic hyperlinks to update a value on a form. There can be multiple input boxs so i'm trying this <form method="post" name="video"> <input type="text" name="data_db_database_id id="data_db_database_id" value="db_data_value" maxlength="4" size="4"></td> </form> PHP: This loads from a database in which the table has 2 rows so on the screen i have 2 input boxes with names of "data01", "data02" and id's of "data01","data02" the form details are outside of the loop I have 1 java script function called 'setdefaultvalue' and i have a dynamic hyperlink loaded next to each box to set a default value if i need to. the calling code is <a href=# onclick="javascript:return setdefaultvalue(7551)"ENCTYPE="multipart/form-data">Set default</a> PHP: Which calls the below value and set the default value for the first field and works perfectly. function setdefaultvalue(value){ var MyElement = document.video.data01; MyElement.value = value; } PHP: However if I try and make the function take a input box via calling it. I can't get it to work. function setdefaultvalue(value,whatele){ var MyElement = document.video.getElementById(whatele); MyElement.value = value; } PHP: And the hyper link code is below <a href=# onclick="javascript:return setdefaultvalue(7551,'data01')"ENCTYPE="multipart/form-data">Set default</a> PHP: Anyone able to help me out on this one. $10 via paypal for the first person to give the correct solution
replace this var MyElement = document.video.getElementById(whatele); with var MyElement = document.getElementById(whatele);
The part I forgot to add about this was it's using the smarty php overlay but shouldn't make too much of a difference to the java script as long as it's properly setup