Discussion:
Dynamically adding to a div
(too old to reply)
Michelle
2005-08-23 00:53:50 UTC
Permalink
I have a div that is initially empty. Clicking on a button will add some
text boxes and other controls so the user can add additional records. In IE
all works fine but in Netscape 7.0 when I add another "record" the values
for all previous controls within the div are wiped out. In the javascript
function where I add on to the html in the div if I capture all the data in
the previous "records" then after adding the new record I can repopulate all
the previous controls. Is this the best way to do this or is there another
way to preserve the data?
--
Thank You.

Michelle
Daniel Kirsch
2005-08-23 07:42:25 UTC
Permalink
Post by Michelle
I have a div that is initially empty. Clicking on a button will add some
text boxes and other controls so the user can add additional records. In IE
all works fine but in Netscape 7.0 when I add another "record" the values
for all previous controls within the div are wiped out. In the javascript
function where I add on to the html in the div if I capture all the data in
the previous "records" then after adding the new record I can repopulate all
the previous controls. Is this the best way to do this or is there another
way to preserve the data?
This doesn't seem to be a CSS question but more a DHTML question which
might be asked in a javascript group.

When adding additional elements I don't see any need to save and restore
allready defined values. Just add your elements e.g. by using DOM methods:

var elm = document.createElement("div");
elm.className = "dynamic-elm";
elm.appendChild(document.createTextNode("hello"));
document.body.appendChild(elm);

Daniel
Michelle
2005-08-25 01:58:14 UTC
Permalink
Thanks Daniel. I will try that. Sorry for the mis-post.
--
Thank You.

Michelle
Post by Daniel Kirsch
Post by Michelle
I have a div that is initially empty. Clicking on a button will add some
text boxes and other controls so the user can add additional records. In
IE all works fine but in Netscape 7.0 when I add another "record" the
values for all previous controls within the div are wiped out. In the
javascript function where I add on to the html in the div if I capture
all the data in the previous "records" then after adding the new record I
can repopulate all the previous controls. Is this the best way to do
this or is there another way to preserve the data?
This doesn't seem to be a CSS question but more a DHTML question which
might be asked in a javascript group.
When adding additional elements I don't see any need to save and restore
var elm = document.createElement("div");
elm.className = "dynamic-elm";
elm.appendChild(document.createTextNode("hello"));
document.body.appendChild(elm);
Daniel
Loading...