Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic form content problem in Firefox

Status
Not open for further replies.

mrbond00

Technical User
Oct 23, 2001
3
AU
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.
 
Fixed -- it seems I had the <form> tag nested in the wrong table which caused this Firefox behaviour.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top