chipowski
Members-
Posts
24 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
chipowski's Achievements
Newbie (1/5)
0
Reputation
-
No worries. Well cause it's missing out the whole of the while bit I guess the query is not returning anything. But I'm also not sure the while loop is using the right syntax. Could you try changing the page to this and see what happens? <html><body> <? require "config.php"; $TERM=$_POST['TERM']; $CURR=$_POST['CURR']; $COURSE=$_POST['COURSE']; $TITLE=$_POST['TITLE']; $AUTHOR=$_POST['AUTHOR']; $PUBLISHER=$_POST['PUBLISHER']; $INSTRUCTOR=$_POST['INSTRUCTOR']; $query = "SELECT * FROM SUMMER WHERE TERM = '$TERM' AND CURR = '$CURR' AND COURSE = '$COURSE' order by INSTRUCTOR"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = ""; while($row = mysql_fetch_array($qry_result)) { $display_string .=<tr><td colspan=3><b>Instructor: $row[iNSTRUCTOR]</b></td></tr><tr><td> </td></tr><tr><td colspan=2 rowspan=4><img src=\"Merchant5/$row[thumbnail]\" /></td><td><a href=\"Merchant5/$row[TITLE]\" onclick=\"return GB_showCenter('Product', this.href)\"> $row[TITLE]</a></td></tr><tr><td>Author: $row[AUTHOR]</td></tr><tr><td>Publisher: $row[PUBLISHER] <br /> </td></tr><tr><td><a href=\"Merchant5/$row[TITLE]\" onclick=\"return GB_showCenter('Product', this.href)\"><img src=\"Merchant5/buybooksnow.png\" /></a></td></tr><tr><td colspan=3><br /><hr /><br /></td></tr> } echo "<table style='color:#fff;'>"; echo $display_string; echo "</table>"; ?> </body></html>
-
You've put the alert in the wrong place. Can you change that last function to this: function get_Results(TERM,CURR,COURSE) { var strURL="dd3ck.php?TERM="+TERM+"&CURR="+CURR+"&COURSE="+COURSE; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { alert("Response "+req.responseText); document.getElementById('RESULTS_div').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } }
-
Well I can't test this out cause of work restrictions but this is what I reckon should work. First you need to create a new function under the function "function get_COURSE(CURR)". It's the same function again but calling your dd3 page and updating an additional div: function get_Results(<your variables>) { var strURL="dd3ck.php?<your variables>="+<your variables>; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('RESULTS_div').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } Then just before the line </form> you need to add something like this: <input type="button" value="Click Here" onClick="get_Results();"> And finally add a new div. <div id="RESULTS_div"> </div> I'm pretty sure this should get you going along the right lines.
-
You can see the response is coming back ok if you change the get_COURSE function to what's below. There is an extra line displaying the response text to screen: alert(req.responseText); function get_COURSE(CURR) { var strURL="findCOURSE.php?CURR="+CURR; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { alert(req.responseText); document.getElementById('COURSE_div').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } I can get all 3 populating by changing the 2nd & 3rd divs to below: <div id="CURR_div"> </div> <div id="COURSE_div"> </div> Can't trace the problem that prevents the page working with your current code but this solution seems to work nicely. Hope this helps you out.
-
Hi. Just managed to get the alert to work based on your very first set of code. The error is in this line: Alert("Ajax Sent"); It should be: alert("Ajax Sent"); Simply need to change the capital A of alert to lowercase. Let me know if you can get the alert message now. I've not looked into populating the second drop down as that will be very straightforward but do let me know if you need any more help.
-
Can you post the contents of constellation.php with any db connection details removed if you are using a db connection. Also if you are using a db, can you post the values from your tables.
-
Ok - was worth a shot. I'll have a look at this when back home - in work now so got limited access to stuff
-
Hi. I think you simply need to defined the ajax function prior to defining the drop down contents. Try this: <html> <head> <script type="text/javascript"> function ajax(str) { if (str=="") { document.getElementById("ajaxResult").innerHTML="Constellation: <select name=\"fleetLocationConstellation\"><option value=\"\">Select Region First</option></select>"; 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("ajaxResult").innerHTML=xmlhttp.responseText; } } Alert("Ajax Sent"); xmlhttp.open("GET","constellation.php?r="+str,true); xmlhttp.send(); } </script> </head> <body> <?php echo "<form name=\"createFleet\" method=\"post\" action=\"scripts/fleet.php\">"; echo "<input name=\"fleetSize\" type=\"hidden\" value=\"1\">"; echo "Fleet Location: <select name=\"fleetLocationRegion\" onchange=\"ajax(this.value)\">"; echo "<option value=\"\">Selecte Region</option>"; echo "<option value=\"aridia\">Aridia</option>"; echo "<option value=\"blackrise\">Black Rise</option>"; echo "<option value=\"derelik\">Derelik</option>"; echo "<option value=\"devoid\">Devoid</option>"; echo "<option value=\"domain\">Domain</option>"; echo "<option value=\"essence\">Essence</option>"; echo "<option value=\"genesis\">Genesis</option>"; echo "<option value=\"heimatar\">Heimatar</option>"; echo "<option value=\"kador\">Kador</option>"; echo "<option value=\"khanid\">Khanid</option>"; echo "<option value=\"korazor\">Korazor</option>"; echo "<option value=\"lonetrek\">Lonetrek</option>"; echo "<option value=\"metropolis\">Metropolis</option>"; echo "<option value=\"moldenheath\">Molden Heath</option>"; echo "<option value=\"placid\">Placid</option>"; echo "<option value=\"sinqlaison\">Sinq Laison</option>"; echo "<option value=\"solitude\">Solitude</option>"; echo "<option value=\"tashmurkon\">Tash-Murkon</option>"; echo "<option value=\"thebleaklands\">The Bleak Lands</option>"; echo "<option value=\"thecitadel\">The Citadel</option>"; echo "<option value=\"theforge\">The Forge</option>"; echo "<option value=\"vergevendor\">Verge Vendor</option>"; echo "</select>"; echo "<div id=\"ajaxResult\">"; echo "Constellation: <select name=\"fleetLocationConstellation\">"; echo "<option value=\"\">Select Region First</option>"; echo "</select>"; echo "</div>"; echo "<input name=\"submit\" type=\"submit\" value=\"Create Fleet\">"; echo "</form>"; ?> </body> </html>