View Full Version : retreiving content of a div

04-10-2003, 03:38 PM
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...

04-10-2003, 03:39 PM
Specify what you mean when you say "content".

HTML content?
Form data?
Element list?


04-10-2003, 03:45 PM
all of the above :)

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

<div id="content">
<input type="textfield" value="bladibla">
<input type="checkbox" value="true">

<input type=button value="submit">

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


<input type="textfield" value="bladibla">
<input type="checkbox" value="true">

04-10-2003, 04:05 PM
Oh. Uhh, quick and dirty solution.

<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>' );


<body onload="">
<div id="blah">
Name <input type="text" name="" />
<br />
<input type="submit" name="Submit" value="Submit" />
blah blah
<input type="button" value="Try it" onclick="openWithContent( 'blah', 0 )" />

04-11-2003, 07:38 AM
wow thx m8


04-11-2003, 07:48 AM
hmmm can you explain me something

What does that prop ?

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

04-11-2003, 07:51 AM
A true value (1) will get the contents of the DIV and the div itself.

outerHTML vs. innerHTML

04-11-2003, 07:53 AM
aaaaaaaah ok :)


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum