Jump to content

chipowski

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

chipowski's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi. Can you repost or attach your main.php with the new function that was added. Are find course and find curr the same as when you first posted them? I just want to make sure I'm looking at the right code.
  2. The reason the query is returning nothing is because the selected values are are not posting to dd3ck.php. Not sure why this is happening at the moment.
  3. ok. no you're right - if your php does work when not posting to a div then there's something else up. i can't really look into this properly till I'm back home. will get back to you soon
  4. Or it might need to be on what I've just put on there: echo "$display_string";
  5. 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>
  6. 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); } }
  7. In the new function you've created, below the line: if (req.status == 200) { Could you add this line: alert("Response "+req.responseText); What is printed to screen when you submit your form?
  8. 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.
  9. I have the page loading fine here: http://www.piano-tuna.com/ajax/main.php If you look at your page source the code is being truncated at the second div. Did you try changing the curr and course div to below?: <div id="CURR_div"> </div> <div id="COURSE_div"> </div>
  10. 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.
  11. 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.
  12. 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.
  13. Ok - was worth a shot. I'll have a look at this when back home - in work now so got limited access to stuff
  14. 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>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.