Click to See Complete Forum and Search --> : creating forms


VinceIO
02-08-2003, 07:44 AM
Can I use javascript to dynamically create an html form?

For example, I want to use a for loop to cycle 5 times and create a form with 5 separate sets of radio boxes, and have the javascript create the name for each set of radio boxes.

I can't get it to work though.

I am using this:

document.write('<INPUT TYPE=RADIO NAME="question"' + (questionIndex + 1) + 'VALUE="b">' + optionB);

where questionIndex and optionB are variables.

I wanted the name of the radio boxes to be question1, question2, etc.

Thanks.

luvbytes
02-08-2003, 08:32 PM
Have a look at 'SurveyBoks' at http://www.scripboks.com/ which is a dynamic form creator: if you download a copy, you can rip the JavaScript apart - it's mostly just concatenating strings with a for...loop and document.write_ing the result to the page.