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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript function to capture output data into variable?

Status
Not open for further replies.

Guern

Programmer
Jun 22, 2001
91
GB
Hi,

Sorry, total Javascript newbie here.

I have a function that needs me to supply HTML code as a variable.

What I have is a function that already exists that dumps the code to screen. If I supply this function instead of a variable, that's what happens, and I get a javascript error.

Is there anyway to capture the output of that function to a variable, then supply the variable to the new function?

just to clarify, in case it's not clear

a function show_records() dumps data to screen

a function do_somthing($variable) that I need to use

I try do_somthing(show_records()), but that does not work as the data is dumpped to output.

How do I
$htmlcode = show_records()
do_somthing($htmlcode)


Thanks for anyone who can point me in the right direction.

Paul
 
[tt]function y(x) {
[blue]return[/blue] "<"+x+">"+"nothing"+"</"+x+">"
}
function do_something(x) {
alert(x)
}
var t=y("body");
do_something(t);
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top