...

View Full Version : Javascript - form elements and string concatenation



btcodeman
09-29-2003, 09:47 PM
Totally forgotten how to get round the following problem.

I am trying to insert a variable(value) into a forms.element command to allow me to check particular element by it's name. Code:-

var v_name = "aq1";
if (document.questions.elements[' + v_name + '][0].checked) {

The above just reads the command as v_name not the content, any help appreciated.

Thanks

cheesebag
09-29-2003, 09:52 PM
[response deleted to keep liorean from doing anything rash]

Great link, tho....

http://www.litotes.demon.co.uk/js_info/sq_brackets.html

liorean
09-29-2003, 09:53 PM
Heh. try changing it from [' + v_name + '] to plain [v_name]

liorean
09-29-2003, 09:54 PM
Ah, cheesebag beat me to it...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum