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 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'> 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 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. 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); 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); 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 Link to comment https://forums.phpfreaks.com/topic/255282-pass-php-variable-value/#findComment-1308868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.