Log in

View Full Version : How to pass variable from one function to the other??



shachi
09-05-2006, 05:26 PM
Hello all again,
Can anyone tell me how do I pass one variable from one function to the other?? I tried this:



<script ...>
function test1(){
var hello = "Hello World!!!";
alert('from function one '+hello);
test2();
}
function test2(){
alert(hello);
}
</script>


but doesn't work.:(

do I use this??:



function test1(){
var hello = "Hello World!!!";
alert('from function one '+hello);
test2(hello);
}
function test2(hello){
alert(hello);
}


or this:



hello = "Hello World!!!";
function test1(){
alert('from function one '+hello);
test2();
}
function test2(){
alert(hello);
}

blm126
09-05-2006, 10:35 PM
I think I answered your question in this (http://www.dynamicdrive.com/forums/showthread.php?t=12849&page=2) thread.

shachi
09-06-2006, 05:11 AM
Thanks blm126, I just read that thread before this.:)