Darkmatter5 Posted June 5, 2009 Share Posted June 5, 2009 Here's the HTML <script type="text/javascript" src="/library/scripts/selectclass.js" /></script> <select name='class' method='get' class='text_boxes' onchange='showClassdescr(this.value)'> <option value='6'>Charismatic</option> <option value='5'>Dedicated</option> <option value='2'>Fast</option> <option value='4'>Smart</option> <option value='1'>Strong</option> <option value='3'>Tough</option> </select> <div id="class_descr"><b>Class description will display here when a class is chosen.</b></div> Here's the Javascript file var xmlhttp function showClassdescr(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="/library/scripts/getclassdescr.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) { document.getElementById("class_descr").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } Here's the getclassdescr.php file <?php include_once('library/config.php'); $q=$_GET["q"]; $result=mysql_query("SELECT descr FROM classes WHERE class_id='$q'"); while($row=mysql_fetch_array($result)) { echo "$row[descr]"; } ?> Here's the file locations pcbuilder.php /library/config.php /library/scripts/getclassdescr.php /library/scripts/selectclass.js When I change the selection it does nothing. How can I test this a piece at a time or does anyone readily see the error? Thanks! Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 7, 2009 Share Posted June 7, 2009 Are your paths correct? Try changing url to the direct URL instead of just /library/.... And your include_once should be '../config.php' right? 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.