PDA

View Full Version : Javascript: Concatenate passed variable to name of form element?



ozefrog
July 27th, 2009, 00:21
Hi,

Say I have a form with elements 'textbox1' thru to 'textbox10'. I am trying to use a javascript function to pass the returned row ID from an SQL database for example:

<input type="text" name="textbox1" value="" onclick="javascript:functionname(<?= $sql_rowid ?>)" />

I want to be able to concatenate the passed row ID to a form element name. This is incorrect of course, but it may give an insight into what I am attempting to do:

document.form_name.textbox + passedSQLRowID.value

Therefore, I am able to access the value of 'textbox1'...

Any ideas? I have been unable to find a way to do this using Google and W3Schools.com as my best friends :P

Thanks in advance,

Zoe.