Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
New fields inserted as innerHTML disappear
Old 11-07-2006, 09:43 PM New fields inserted as innerHTML disappear
Junior Talker

Posts: 2
Name: Mike B
Trades: 0
I am developing a Popup framework which will use AJAX type server interactions to update a wizard that will be running in a popup window. (I know... popups... but it's an internal app and they know)

There is a main Popup page (well formed xhtml) that is updated with a page fragment (more well formed xhtml) that contains a few context appropriate fields which are inserted into a named <div> in the main popup <form>. This all works, it displays as expected and it looks great. The problem is... although the fields "show up" and they get displayed just like I want them to, they don't seem to really exist in the DOM - they are not found in the form.elements collection. Only the fields which exist in the original main popup page are found. The exact same behavior occurs in IE (window.showModalDialog) and FF (window.open), and no errors are shown in the FF JavaScript Console.


This is how I insert the page fragement:
var responseXml = req.responseText;
var div = document.getElementById(divName);
div.innerHTML = responseXml;
As there are no apparent errors, I'm not sure what other code would be relevant to post... This is baffling me!

I just found this site today, looks like a great resource!
Mike B
MikeB_jsforum is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-08-2006, 02:06 AM Re: New fields inserted as innerHTML disappear
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
To add items into the form collection you have to add them directly into the form element, simply adding them into a div that is inside a form doesn't mean they will exist in the form as well. The form elements need to be added as a child element (appendChild method) to the form.

Take a look at http://www.quirksmode.org/dom/domform.html to see how it is done with DOM scripting, you'll notice their script inserts the items before an empty <span> which is a child of the form so makes the added items a child element of the form also.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-09-2006, 01:18 AM Re: New fields inserted as innerHTML disappear
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
i think to add items into a form you can do that only by adding them to a form or a table n the form.but not to a div.
seomumbai is offline
Reply With Quote
View Public Profile
 
Old 11-09-2006, 02:33 PM Re: New fields inserted as innerHTML disappear
Junior Talker

Posts: 2
Name: Mike B
Trades: 0
Chris,

That was the right clue I needed... stumbled through the usual IE/Mozilla incompatibilities and now it's working great.

Thanks!
Mike
MikeB_jsforum is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to New fields inserted as innerHTML disappear
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21902 seconds with 12 queries