iceblox Posted July 20, 2007 Share Posted July 20, 2007 Hi Guys, I have a ajax/php script which currently carrys one variable set by the value"" field. I want to carry another variable if possible this is my script how would i achieve this? GetUser.php: <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'fmpr', '219905'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mobile", $con); include ("http://www.freemobilephonereviews.com/cron/deals_network.php?NetworkName=$q"); mysql_close($con); ?> Display Page <div align="center"> <center> <table border="0" cellpadding="2" cellspacing="3" style="border-collapse: collapse" bordercolor="#111111" width="78%" id="AutoNumber1"> <tr> <td width="14%"> <p align="center"><a target="_blank"> <a href="#" onClick="showUser(this.value)" value="Orange"><img src="http://www.urmob.co.uk/i/networks/Orange.gif" border="0" width="26" height="27"></a></td> <td width="14%"> <p align="center"><a target="_blank"> <a href="#" onClick="showUser(this.value)" value="O2"><img src="http://www.urmob.co.uk/i/networks/O2.gif" border="0" width="28" height="27"></a></td> <td width="14%"> <p align="center"><a target="_blank"> <a href="#" onClick="showUser(this.value)" value="Vodafone"><img src="http://www.urmob.co.uk/i/networks/Vodafone.gif" border="0" width="29" height="27"></a></td> <td width="14%"> <p align="center"><a target="_blank"> <a href="#" onClick="showUser(this.value)" value="T-Mobile"><img src="http://www.urmob.co.uk/i/networks/T-Mobile.gif" border="0" width="22" height="27"></a></td> <td width="14%"> <p align="center"><a target="_blank"> <a href="#" onClick="showUser(this.value)" value="Virgin"><img src="http://www.urmob.co.uk/i/networks/Virgin.gif" border="0" width="47" height="27"></a></td> <td width="15%"> <p align="center"><a target="_blank"> <a href="#" onClick="showUser(this.value)" value="Three"><img src="http://www.urmob.co.uk/i/networks/Three.gif" border="0" width="22" height="27"></a></td> </table> </center> </div> <center><div id="txtHint"> <?php include ('http://www.freemobilephonereviews.com/cron/deals.php?ModelID=' . $ModelID . ''); ?> </div></center> .Js File var xmlHttp function showUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getuser1.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Any help would be apprecaited... Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 20, 2007 Share Posted July 20, 2007 You'll need to modify the .js file: var url="getuser1.php" url=url+"?q="+str url=url+"&yourothervariable=somevalue" url=url+"&sid="+Math.random() And then the php file: <?php $q=$_GET["q"]; $yourothervariable = $_GET['yourothervariable']; Obviously you'll need to change the js to reflect what you actually want to pass in the url. Quote Link to comment Share on other sites More sharing options...
iceblox Posted July 21, 2007 Author Share Posted July 21, 2007 Ok, so using that would i be able to change "&Yourothervariable" through the display page? Quote Link to comment Share on other sites More sharing options...
iceblox Posted July 21, 2007 Author Share Posted July 21, 2007 Sorry that probably did come out as well as it should have done. Currently the script allows me to change the network via the display page. Want i would like to be able to is change the network and get the ModelID through a variable set in the display page. If this makes sense? Phil Quote Link to comment Share on other sites More sharing options...
iceblox Posted July 21, 2007 Author Share Posted July 21, 2007 After picking my brains a bit more i worked out the answer. Thanks GingerRobot for your input. Cheers Quote Link to comment 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.