www.webdeveloper.com
Results 1 to 5 of 5

Thread: Help needed with retreiving data from form.

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Exclamation Help needed with retreiving data from form.

    I need to retrieve data from a form and display it on the webpage with document.write. My funtion works for the first element and stops there. Any ideas on what is wrong?

    Here is the funtion:

    function newText() {


    var my_var=document.getElementById("formId");


    for (var i=0;i<my_var.length;++i){
    document.write(my_var[i].value + "<br >");


    }



    }

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    you can't use document.write very well once the page loads.
    it will create a new blank page if you do, and all your html and javascript will be gone.

  3. #3
    Join Date
    Dec 2008
    Posts
    4
    That doesn't matter in this case. All I need is a blank page showing the contents of the form. I can get the first element of the form but not the rest. I somehow need to loop through them...

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    hmmm.

    you can do it all at once using a string buffer:

    Code:
    var buff ="";
    for (var i=0;i<my_var.length;++i){
     buff+= my_var[i].value + "<br >";
    }
    document.write(buff);

  5. #5
    Join Date
    Dec 2008
    Posts
    4
    Where would I insert:

    var my_var=document.getElementById("formId");

    To "get the data" from my form?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles