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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question retreiving content of a div

    hey guys and gals,

    i'v got a big problem...

    i need to retreive the content, including elements from a div.

    is this possible? i know that you can make a page editable. but can you "copy/paste" total content...

    this is how it should be:

    in a page is a div with id=content. In this div are all different form elements, with values. Below this div is a button, when you press that button a popup appears with the contents (all form elements + values) of the previous div.

    can this be done...

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Specify what you mean when you say "content".

    HTML content?
    Form data?
    Element list?

    ???
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    all of the above

    like everything that is in that div : tables, form elements like textfields checkbuttons,...

    <div id="content">
    bladibladibla
    <form>
    <input type="textfield" value="bladibla">
    <input type="checkbox" value="true">
    </form>
    <table><tr><td>hadiho</td></tr></table>
    </div>

    <input type=button value="submit">


    when pressing that button a popup must appear with everything thats in the div


    popup:

    bladibladibla
    <form>
    <input type="textfield" value="bladibla">
    <input type="checkbox" value="true">
    </form>
    <table><tr><td>hadiho</td></tr></table>

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh. Uhh, quick and dirty solution.
    Code:
    <html>
    <head>
    <title>Test</title>
    
    <script type="text/javascript">
    
    function openWithContent( id, outer )
    {
        var prop = ( outer ) ? 'outerHTML' : 'innerHTML';
        var myWin = window.open( '', 'myWin', 'width=500,height=400' );
        var d = myWin.document;
        d.write( '<html><head><title>Blah</title></head><body>' );
        d.write( document.getElementById( id )[prop] );
        d.write( '</html>' );
    }
    
    </script>
    
    
    </head>
    <body onload="">
    <h1>Test</h1>
    <div id="blah">
        <form>
            Name <input type="text" name="" />
            <br />
            <input type="submit" name="Submit" value="Submit" />
        </form>
        <p>
            blah blah
        </p>
    </div>
    <input type="button" value="Try it" onclick="openWithContent( 'blah', 0 )" />
    </body>
    </html>
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wow thx m8

    U ROCK

  • #6
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmmm can you explain me something

    What does that prop ?

    both onclick="openWithContent( 'blah', 1 );" and onclick="openWithContent( 'blah', 0 );" work

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    A true value (1) will get the contents of the DIV and the div itself.

    outerHTML vs. innerHTML
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #8
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    aaaaaaaah ok

    THX !


  •  

    Posting Permissions

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