anujgarg Posted September 16, 2008 Share Posted September 16, 2008 I have a javascript function creating a string and assigned into a variable named url ie url = http://localhost/abc/xyz/2/5/7 Also, This function does not return this string, as this string is further being used in AJAX incorporation. Now I want to get this string in another javascript function. Is it possible to do this? (As the prev function is not returning the desired string.) Link to comment https://forums.phpfreaks.com/topic/124482-javascript-function-call/ Share on other sites More sharing options...
Garethp Posted September 16, 2008 Share Posted September 16, 2008 Yeah, google Javascript Global Variable or use the Javascript Return function Link to comment https://forums.phpfreaks.com/topic/124482-javascript-function-call/#findComment-642824 Share on other sites More sharing options...
anujgarg Posted September 16, 2008 Author Share Posted September 16, 2008 As I said that I can't return the string from the first function as it is being used further as AJAX incorporation. In my case here, I can only use global variable, but how? Link to comment https://forums.phpfreaks.com/topic/124482-javascript-function-call/#findComment-642835 Share on other sites More sharing options...
virtualdevl Posted September 16, 2008 Share Posted September 16, 2008 What about setting the innerHTML or value of an element in the first function, then reading that value with the second function? function setURL() { var url = 'http://localhost/abc/xyz/2/5/7'; getElementById('elName').innerHTML = url; } function getURL() { //blah, get innerHTML from elName } Link to comment https://forums.phpfreaks.com/topic/124482-javascript-function-call/#findComment-642838 Share on other sites More sharing options...
Garethp Posted September 16, 2008 Share Posted September 16, 2008 var myValue; function setValue() { myValue = "test"; } function getValue() { alert(window.myValue); // yup, it's "test" } Link to comment https://forums.phpfreaks.com/topic/124482-javascript-function-call/#findComment-642847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.