473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with IE's innerHTML and <form> tags??!?!

I'm having a really hard time with IE's innerHTML property and <form>
tags. If I use this code:

myDiv.innerHTML = "<form>This is a test</form>" in fireFox, the div tag
shows the content. However, if I do the same in IE, nothing happens.
For whatever reason, IE will not take that content.

Has anybody run into this, and what's a good solution? (Please, no "use
FireFox!" answers - we have users that use both equally).

Thanks for any help.

Feb 15 '06 #1
3 3491


Nebulus wrote:
I'm having a really hard time with IE's innerHTML property and <form>
tags. If I use this code:

myDiv.innerHTML = "<form>This is a test</form>" in fireFox, the div tag
shows the content. However, if I do the same in IE, nothing happens.


Complete example

var div = document.createElement('div');
div.id = 'div1';
div.innerHTML = '<form>Kibology for all.</form>';
document.body.appendChild(div);
alert(div.outerHTML);

works fine for me with IE 6 on Windows XP, the div is rendered and the
outerHTML looks correct.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 15 '06 #2
Thanks for the help. I tested with some basic HTML/JS and was able to
put anything I wanted into the DIV tag.

However, I'm using a page that has a more complex layout and it also
uses some flash. When I try to add a form to a DIV in that page using
this exact code:

objDiv = document.getElementById('testDiv');
objDiv.innerHTML = '<form id="testForm" name="testForm"
method="GET">Test Form</form>';

then I get an unknown runtime error. Any ideas?

Feb 15 '06 #3
Um, nevermind.... I FINALLY figured it out. I had this code:

<form>
....inputs here...
<div id="testDiv">my test div here</div>
</form>

Obviously, you can't nest forms. Once I pulled the DIV out of the form,
it worked. DUH!

Feb 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayfarer | last post by:
Hi, I have a database of quotes on my website that uses an Access 97 database (I'm cheap...I have an old copy of MS Office). I have one page that builds a form <select> from a SQL statement...
2
by: Keiron Waites | last post by:
I have the following code: <input type="text" name="search" class="search_top"> <a href="" onclick="window.location='search.inc.php'+document..search. value; return false;"...
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
10
by: Phlip | last post by:
HTMListas: (Apologies for I can't Google for this - too many common words.) I have a <form> tag. It thinks I want a <p> break before and after the form. I don't. (My forms are sneaky and...
2
by: Larry | last post by:
Is it true that I can only have one <FORM> tag per aspx page? I have heard this and seen this on some other .net forums. Why is this necessary? How do you work around the situation where you...
4
by: George | last post by:
I'm using .NET framework 1.1 and VS.NET 2003 for a aspx web form. There is a DropDwonList on the page and its SelectedIndexChanged event is fired to the server normally, until when I add another...
3
by: Lakshmi Narayanan.R | last post by:
Hi Experts MasterPage.master In this master page, no <form> tag is used. Register.aspx Here also no <form> tag. But the form elements are working fine inside the <asp:content> tag Is it Ok...
4
by: rob c | last post by:
This is a minor thing and only appears in IE (so far), but I'd like to know to correct it (if possible). Whenever I use a form on a webpage, Explorer always leaves a blank line following the...
1
by: Pesho318i | last post by:
hi all I have a jsp-based website. The initial layout of the page is correctly displayed both in FF and IE7. However, when I refresh only a part of the page (e.g. a single jsp, using AJAX), the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.