Hey all
Am trying to make a script to dynamically create a form. All is going good except for creating the select section.
I am using a select box to select the field type (text, password, radio, checkbox, select etc), which will then write to a DIV that will contain the field input.
The specific problem I am facing is the SELECT seems to automatically close the tag before I can put any options.
This outputs the HTML as follows
So it loops the option bit the correct amount of times, it just seems to be ignoring the tags
any help? also i have prob explained it rubbishly so pls say and i will reiterate my point
Am trying to make a script to dynamically create a form. All is going good except for creating the select section.
I am using a select box to select the field type (text, password, radio, checkbox, select etc), which will then write to a DIV that will contain the field input.
The specific problem I am facing is the SELECT seems to automatically close the tag before I can put any options.
Code:
document.getElementById('field1').innerHTML = "<select name=\""+document.formaform.field_name.value+"\">";
for (i=0; i < document.formaform.field_options.value; i++) {
document.getElementById('field1').innerHTML += "<option>a</option>";
}
document.getElementById('field1').innerHTML += "</select>";
This outputs the HTML as follows
Code:
<div id="field1"><select name="gggg"></select>aaaa</div>
So it loops the option bit the correct amount of times, it just seems to be ignoring the tags
any help? also i have prob explained it rubbishly so pls say and i will reiterate my point