Variables pass in javascript

778898

New Member
I have to pass variables from javascript to php. My code is given below:\[code\]<script>function getValue(val,val2){ window.a = val; window.b = val2;}function getValue2(val,val2){ window.c = val; window.d = val2;}function sendvar(){ if(window.a === 'undefined'){ window.a = 0; } if(window.b === 'undefined'){ window.b = 0; } if(window.c === 'undefined'){ window.c = 0; } if(window.d === 'undefined'){ window.d = 0; }location.href = "http://stackoverflow.com/questions/14088442/count.php?id="+window.a + "&optionname1=" + window.b + "&id=" + window.c + "&optionname1=" + window.d</script><img src="http://stackoverflow.com/questions/14088442/img1.jpg" onclick="getValue('yes','1');"><img src="http://stackoverflow.com/questions/14088442/img2.jpg" onclick="getValue2('no','1');"><button onclick="sendvar();">Click me</button>\[/code\]When getValue function call so only the values of this function pass in href other values should be zero and when getValue2 function call so only the values of this function pass in href other values should be zero. But this is no happening right now.Please tell me where i am wrong?
 
Back
Top