Hi,
I'm using innerHTML to add form elements dynamically into a div (inside "theform"). The problem is that in Firefox, while the new HTML appears correctly ("text2" shows up), the new fields do not become part of "theform" -- meaning that the new form elements are not submitted along with the form.
The page structured roughly like this:
<form name="theform">
<input type="text" name="text1">
<div id="div_1"></div>
<input type="submit">
</form>
<script language="javascript">
document.getElementById("div_1").innerHTML = "<input type='text' name='text2'>";
</script>
i.e. document.forms["theform"].elements["text2"] is undefined while document.getElementById["text2"] will work. In IE, either works (and "text2" is properly submitted as part of "theform").
Thanks for any help.
I'm using innerHTML to add form elements dynamically into a div (inside "theform"). The problem is that in Firefox, while the new HTML appears correctly ("text2" shows up), the new fields do not become part of "theform" -- meaning that the new form elements are not submitted along with the form.
The page structured roughly like this:
<form name="theform">
<input type="text" name="text1">
<div id="div_1"></div>
<input type="submit">
</form>
<script language="javascript">
document.getElementById("div_1").innerHTML = "<input type='text' name='text2'>";
</script>
i.e. document.forms["theform"].elements["text2"] is undefined while document.getElementById["text2"] will work. In IE, either works (and "text2" is properly submitted as part of "theform").
Thanks for any help.