Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2010, 11:36 AM   PM User | #1
u jayakodi
New Coder

 
Join Date: Sep 2010
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
u jayakodi is an unknown quantity at this point
How to Save Dynamically Created Elements

u jayakodi
jayakodiu@yahoo.com

Elements created and added to a web page by scripts are not 'saved' when the page is saved. Two simple js functions presented here can save the dynamically created elements; the script and other details of the page creating them are avoided, as may be needed in a graph plottng routine.

Pl. see the enclosed zip file.
Attached Files
File Type: zip SaveDynamicallyCreatedElementsJS.zip (1.2 KB, 129 views)
u jayakodi is offline   Reply With Quote
Old 10-04-2010, 02:53 PM   PM User | #2
tfburges
Regular Coder

 
Join Date: May 2009
Posts: 425
Thanks: 3
Thanked 62 Times in 61 Posts
tfburges is an unknown quantity at this point
Your best bet would be to use AJAX to query a server-side script (connected to a database or some kind of file storage) that saves the DOM structure as it is created; and of course when the page is loaded, read from the repository to regenerate the created elements.

If you can't use a server-side script, you may be able to do the same using cookies but... cookies... how do they work?

P.S.
Quote:
Originally Posted by http://www.codingforums.com/rules.htm
1.5) No homework assignments - Do not post your entire homework assignment and request that other members do it for you. This is considered cheating, and your thread may even be used by your school to prove your guilt. Now, you may ask for advice or help on a specific aspect of your assignment that you're having trouble with. Use common sense as far as what's acceptable in terms of soliciting help with homework assignments.
tfburges is offline   Reply With Quote
Old 04-26-2011, 01:51 PM   PM User | #3
hotwheelharry
Regular Coder

 
Join Date: Jun 2008
Posts: 102
Thanks: 6
Thanked 9 Times in 9 Posts
hotwheelharry is an unknown quantity at this point
hmm, server side scripts for that... is that really the best bet?

I think you could use localStorage. Much faster/easier to make work.

Cookies... lol.
hotwheelharry is offline   Reply With Quote
Old 04-27-2011, 12:36 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Quote:
Originally Posted by u jayakodi View Post
u jayakodi
jayakodiu@yahoo.com

Elements created and added to a web page by scripts are not 'saved' when the page is saved. Two simple js functions presented here can save the dynamically created elements; the script and other details of the page creating them are avoided, as may be needed in a graph plottng routine.

Pl. see the enclosed zip file.
That is an IE only solution, as it is based on ActiveX, which is a specific IE language. Don't mention that it will work only under Windows OS. So that, in fact, that is not a JavaScript solution, it is a limited ActiveX / Windows one.

For a modern crossbrowser solution there are two possibilities: either a server-side code (with or without AJAX) or the HTML5 features, like local Storage or even dataBase Storage.

Cookies, are, indeed, improper, as they can store limited content of data.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 04-27-2011 at 12:40 PM..
Kor is offline   Reply With Quote
Old 10-13-2011, 04:40 PM   PM User | #5
yogesh249
New to the CF scene

 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
yogesh249 is an unknown quantity at this point
Not true

NO, that is not true....
dynamically added elements are sent to the server side....

I have tested it using a HELLOWORLD type program.

I wrote a html form, a javascript method that adds dynamic fields to the html form. and on submission I can see the values of dynamic fields that were generated via javascript method.
yogesh249 is offline   Reply With Quote
Old 10-13-2011, 06:19 PM   PM User | #6
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,452
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
for smaller pages:

Code:
window.open('data:text/html,'+   escape( "<html>"+     
      document.documentElement.innerHTML+
"</html>"));
for bigger pages, it can take a LONG time for this to run. i've never seen it actually crash, but it will freeze firefox for a while on big pages (>20kb of html)...
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.8% IE9:11.4% IE10:6.5%
rnd me is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:26 PM.


Advertisement
Log in to turn off these ads.