I have a radio button as an input and while onclick the Ajax java script function "processvalue" will be called by passing value of the radio button ('1' or '0') as well as a php variable...(say '<?php echo $event['eventid']; ?>'). How can I go about passing more than 1 arguments in the function and also then pass the values to the PHP file that will be called via the ajax function? Example: PHP/HTML: <?php echo "YES"; ?>: <input type="radio" name="vote" value="1" onclick="getVote(this.value,'<?php echo $event['eventid']; ?>')" /> <?php echo $lang['NO']; ?>: <input type="radio" name="vote" value="0" onclick="getVote(this.value),'<?php echo $event['eventid']; ?>'"/> Ajax: function processvalue(vote,id) { if (str.length==0) { document.getElementById("Answer").innerHTML=""; return; } var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.getElementById("Answer").innerHTML=xmlHttp.responseText; } } var url="show.php"; url=url+"?q="+vote; url=url+"&t="+id; xmlHttp.open("GET",url,true); xmlHttp.send(null); } PHPshow.php) <?php $xvote = $_REQUEST['vote']; $xevent=$_GET["id"]; echo $xvote; echo $xevent; ?>
in your code, you call show.php and pass 2 variables to it: the variable names are q and t so your show.php page should look like this: $xvote = $_REQUEST['q']; $xevent=$_GET["t"]; echo $xvote; echo $xevent; ok?