Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how to dynamically create forms in xhtml with javascript?

Reply
Thread Tools

how to dynamically create forms in xhtml with javascript?

 
 
Eric Sessoms
Guest
Posts: n/a
 
      10-06-2005
I am trying to create forms on the fly in strict xhtml using
javascript. I won't bore you with why, but I should mention that I'm
only interested in the very latest versions of Mozilla based browsers.

The basic problem is that the forms do not display. I've included a
minimal sample below that illustrates this. It validates, I get no
javascript errors at run time, and most disconcerting of all is that
the DOM tree looks right after the page has loaded... but still
nothing.

Help!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test Page</title>
<script type="text/javascript">
<![CDATA[
function init() {
var input = document.createElement('input');
document.getElementsByTagName('p').item(0).appendC hild(input);
}
]]>
</script>
</head>
<body onload="init();">
<form id="form" action="">
<p><!-- The document displays if I include: <input/> --></p>
</form>
</body>
</html>

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-06-2005


Eric Sessoms wrote:

> I am trying to create forms on the fly in strict xhtml using
> javascript. I won't bore you with why, but I should mention that I'm
> only interested in the very latest versions of Mozilla based browsers.


How do you serve the document to Mozilla, as text/html, or as
application/xhtml+xml, or as application/xml or as text/xml?

> var input = document.createElement('input');


You could try with
var input =
document.createElementNS(
'http://www.w3.org/1999/xhtml',
'input'
);
instead. That should fix it if you serve as application/xml or text/xml
which might be the problem.




--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Eric Sessoms
Guest
Posts: n/a
 
      10-06-2005
Damn, you're good. And fast. Yes, I was serving it as text/xml and
your suggestion fixed the problem. Thanks very much!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
convert xhtml to another xhtml using xslt Usha2009 XML 0 12-20-2009 01:13 PM
Should I Convert Site To XHTML or XHTML mobile? chronos3d HTML 9 12-05-2006 04:46 PM
parse URL (href) from xhtml, xhtml -> text, for data hawat.thufir@gmail.com XML 7 02-08-2006 07:39 PM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM



Advertisments