Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning whole page to variable?

Status
Not open for further replies.

Sheltered

Programmer
Nov 26, 2002
55
0
0
GB
Hi, how do i go about assigning the source of my page to a variable?
Why do i want to do this?... because i have a table generated from a database using ASP, i want to save the generated page as a static HTML page on the click of a button. I understand javaScript cannot write to file so if i can assign the source to a variable and stuff the vairable into an <input> then i can use ASP to do the writin.

I have managed so far to get all text (but no HTML) from my page using some javascript i found on another thread, and i can output it into a <textarea>.

onload = function() {
test = document.body.innerText;
document.getElementById(&quot;textspan&quot;).innerText = test;
}

and...
<textarea id=&quot;textspan&quot; cols=&quot;80&quot; rows=&quot;20&quot;></textarea>

The output however is not formatted in anyway.
I also tried using innerHtml but this didnt work at all.

Any ideas on how can get round this?
Thanks

Pete
 
Well... I don't know much of ASP. However I know enough of PHP. May be you'll find the way to translate PHP commands in ASP.

The purpose of the following code is to display a 10 rows table twice. Between ob_start() and ob_end_flush()the output is not sent to the navigator but stored. ob_get_contents() allows to store the content in a string ($myString in the example).
ob_end_flush() sends the output to the navigator and then the first instance of the 10 rows table is displayed.
<? print $myString ?> before closing html tag prints the html code I saved and then it displays the second instance of the 10 rows table.
I hope it will be clear.... I'm not used to write in English.

Code:
<html>
<body><? 
ob_start();?>
<table><? 
// Here I generate some html code.... 
for ($i=0;$i<=10;$i++) {?>
<tr><td><? print $i ?></td></tr><? 
} ?>
</table><?
$myString = ob_get_contents();
ob_end_flush();?>
<br>
<!-- Here I print myString it's like duplicating the table -->
<? print $myString ?>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top