Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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 Attached Files

  • #2
    Regular Coder
    Join Date
    May 2009
    Posts
    425
    Thanks
    3
    Thanked 62 Times in 61 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jun 2008
    Posts
    102
    Thanks
    6
    Thanked 9 Times in 9 Posts
    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.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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.
    Last edited by Kor; 04-27-2011 at 12:40 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #6
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,335
    Thanks
    11
    Thanked 588 Times in 569 Posts
    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 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •