Hi,

I am generating a string from AJAX data which contains forms and submit buttons. I then try to assign this string to a div using innerHTML. This works fine in IE but Firefox strips form tags and every thing in between form tags. How to solve this issue

Example code:

str = "<form action='somepage.php' methid=post><input type=text name=some_field><input type=submit value='Submit'></form>";

document.getElementById('some_div').innerHTML=str;

I am using Firefox version 3.6.16

Thanks

Recommended Answers

Try it

<div id="some_div">&nbsp;</div>
<script>
	var str = '<form action="game.cfm" method="post"><input type="text" name="some_field"><input type="submit" value="Submit"></form>';
	document.getElementById('some_div').innerHTML=str;
</script>
Jump to Post

All 2 Replies

Try it

<div id="some_div">&nbsp;</div>
<script>
	var str = '<form action="game.cfm" method="post"><input type="text" name="some_field"><input type="submit" value="Submit"></form>';
	document.getElementById('some_div').innerHTML=str;
</script>

Dasatti,

You could try hard-coding the <form ...></form> then deliver/insert just its contents.

If that doesn't work then hard code the whole form and show/hide it and change its properties/contents with DOM methods as necessary.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.