Click to See Complete Forum and Search --> : simple question on functions


MadCommando
09-07-2003, 06:22 PM
I tried a quick search and came up more confused than resolved. I have a fairly simple question. How do I run something thru a function and then use the result. I think it has something to do with "return"

ex:

function a()
{
window.thevar=5
newwindow=window.open()
process(window.thevar)
newwindow.document.write(----results from process()------)
}

function process(var)
{
var=var *2
return var}



I know this might be a little vauge, but all I want to know is how to run something thru a function and utilize the returned information.

Fang
09-08-2003, 02:01 AM
Does this explain it:

function ReturnIt(val) {
return val+5;
}
var num=ReturnIt(2);
alert(num);