iceblox Posted July 22, 2007 Share Posted July 22, 2007 Hi Guys; Ive hit a brick wall and it hurts, I hope some one can help! I have an Ajax/PHP script; the script allows a user to select a network to view deals on that network. What i need help with is adding a spanner into the works, this would allow the user to select a phone model via Ajax then select the network so it would carry the two variables. If this makes sense? These are the codes i have so far.. Display Page: <script>var xmlHttp function showUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getdeals.php" url=url+"?q="+str url=url+"&ModelID=<?php echo"$ModelID" ?>" 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; }</script> <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 ("/cron/deals.php?ModelID=' . $ModelID . ''); ?> </div></center> Ajax Page: <?php $q=$_GET["q"]; $ModelID = $_GET['ModelID']; $con = mysql_connect('localhost', 'User', 'Pass'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mobile", $con); include ("/cron/deals_network.php?NetworkName=$q&ModelID=$ModelID"); mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/61277-php-ajax-help/ Share on other sites More sharing options...
GingerRobot Posted July 22, 2007 Share Posted July 22, 2007 Im not quite sure i understand what you are trying to do. Do you mean that you first want the user to select a network, then to have a list of phones displayed, which they then select from, and then you do something else with both these bits of information? Also, in your javascript you have: url=url+"&ModelID=<?php echo"$ModelID" ?>" Where is $ModelID defined? Link to comment https://forums.phpfreaks.com/topic/61277-php-ajax-help/#findComment-304878 Share on other sites More sharing options...
iceblox Posted July 22, 2007 Author Share Posted July 22, 2007 Sorry for not explaining it very well. Ill try again.. With the current Ajax script, it displays the avaliable networks when User selects a network the script only shows the deals on that network. $ModelID is defined in the URL. If no network has been clicked it shows all deals with that $ModelID. Which is working. But what im trying to do is put a list of different colours of that model above the avalible networks. And when they click say "Pink" it will show all the deals for the "Pink" phone but then they could define the list by clicking a network. Does this make more sense? If you require me to I can PM you the test link of what ive got and what i want it to be? Thanks, Phil Link to comment https://forums.phpfreaks.com/topic/61277-php-ajax-help/#findComment-304889 Share on other sites More sharing options...
iceblox Posted July 23, 2007 Author Share Posted July 23, 2007 Anyone got any ideas? Phil Link to comment https://forums.phpfreaks.com/topic/61277-php-ajax-help/#findComment-305648 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.