Not sure what is the level of this question, but any help would be much appreciated.
I have 2 Javascript functions. One of them takes a value as an input. I want to return that same value from second function without passing it from first function to second function. I guess it can be done through Global variable, but not sure how it is done. I dont want to give any input for my second function, i.e. display().
Javascript:
<script language="JavaScript" type="text/javascript">
var p;
function a(imgsrc){
p = imgsrc;
}
function display(){
return p;
}
</script>
HTML:
<a onClick="a('imagesource');">Link</a>
I'm displaying variable return from display() function in HTML (as shown below)
<script type="text/javascript">
document.write(display())
</script>
Whenever Link is clicked, I want 'p' variable to be updated.
Thanks in advance!!!!!!!



Reply With Quote



Bookmarks