Results 1 to 2 of 2
  1. #1
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript to append table data

    I have a small HTML form that generates a results table (calculated by the JavaScript). I need to be able to display this results table at the end of the HTML page that the form sits on. (The web IT team at my company frowns upon opening a new browser window to display this type of data). Here's a simplistic layout of the HTML page with the form:

    .HTML
    .BODY
    .FORM
    .field1=x
    .field2=y
    .field3=z
    .[SUBMIT]
    ./FORM
    ./BODY
    ./HTML

    When user hits the SUBMIT button I want the resultant table to appear at the end of the existing page (or a new iteration of the existing page). I don't think I can get JavaScript to alter the page its sitting on but I should be able to have code which re-prints the entire page (so it can be used to SUBMIT again) and appends this data table. I could use Perl to do this very thing (and I know Perl better than JavaScript) but I don't have time to re-write it.

    I also want the user to be able to see each iteration of this table when they hit the SUBMIT button. So each SUBMIT button will generate this:

    .HTML
    .HTML
    .BODY
    .FORM
    .field1=x
    .field2=y
    .field3=z
    .[SUBMIT]
    ./FORM
    ."OUTPUT TABLE #1"
    .TABLE
    . data data data
    . data data data
    ./TABLE
    ./BODY
    ./HTML

    The 2nd time SUBMIT is pressed, it'll generate:

    .HTML
    .HTML
    .BODY
    .FORM
    .field1=x
    .field2=y
    .field3=z
    .[SUBMIT]
    ./FORM
    ."OUTPUT TABLE #1"
    .TABLE
    . data data data
    . data data data
    ./TABLE
    ."OUTPUT TABLE #2"
    .TABLE
    . data data data
    . data data data
    ./TABLE./BODY
    ./HTML

    Does this make sense? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    1. How can I do this type of output in JavaScript? <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23> I'll have to have tons of print statements to display the initial page with the form, and then somehow append the table and remember how many iterations have bee done.

    2. I'll also need to position the most recent output table such such that it's viewable (so the user doesn't have to scroll down more and more to see it. I can print a link statement for the user to click on to get to the bottom but I'd also like to do the initial scrolling for them when this new page is displayed. How can I do that?

    Thnx, Deb

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: JavaScript to append table data

    <P ID="edit" class=small>(Edited by jscher2000 on 07-Jan-04 18:49. One more link...)</P>This important thing is not clear: do you plan to round-trip to the server when the user clicks Submit?

    If yes, I'm not sure how you preserve previous results in the page. Complicated. Messy. Bad.

    If no, please refer to our earlier thread.

    New Link: Check out How to Build Tables Dynamically on MSDN!

    On question 2, that's a tough one: using an <A NAME="BOOKMARK1"> tag is the quickest, but reloading to that location might trash your code.

Posting Permissions

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