freaker87 Posted January 18, 2012 Share Posted January 18, 2012 I have this code function showprice(str)(str1) { if (str=="") { document.getElementById("txtchem").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtchem").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getchemcom.php?q="+str,true); xmlhttp.send(); i use this <select onchange="showprice(this.value)($amt);" name='fid'> then in getchemcom.php file i get value by $val=$_GET["q"]; but its not working plz help me how can i pass $amt value in getchemcom.php page Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/ Share on other sites More sharing options...
AyKay47 Posted January 18, 2012 Share Posted January 18, 2012 function arguments are separated by a comma, not a whole new set of parenthesis. function showprice(str,str1) and <select onchange="showprice(this.value,<?php echo $amt; ?>);" name='fid'> Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308853 Share on other sites More sharing options...
freaker87 Posted January 18, 2012 Author Share Posted January 18, 2012 how can i get value of $amt on another php page Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308858 Share on other sites More sharing options...
AyKay47 Posted January 18, 2012 Share Posted January 18, 2012 by adding it to the querystring using AJAX as you have done, however, i do recommend jquery's Ajax API. Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308860 Share on other sites More sharing options...
freaker87 Posted January 18, 2012 Author Share Posted January 18, 2012 i think i have to add something here xmlhttp.open("GET","getchemcom.php?q="+str,true); Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308861 Share on other sites More sharing options...
AyKay47 Posted January 18, 2012 Share Posted January 18, 2012 i think i have to add something here xmlhttp.open("GET","getchemcom.php?q="+str,true); str1 holds your php variable value, you will need to add that onto the querystring. xmlhttp.open("GET","getchemcom.php?q="+str&s=str1,true); Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308867 Share on other sites More sharing options...
freaker87 Posted January 18, 2012 Author Share Posted January 18, 2012 thnx but i use ............ add this line var str2 = <? echo $amt ?>; & xmlhttp.open("GET","getchemcom.php?q="+str+"&amt="+str2,true); now its workin fine... & thnx Quote Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308868 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.