Greaser9780 Posted March 2, 2007 Share Posted March 2, 2007 Here is my select box that calls the js: <html> <head> <script src="selectuser.js"></script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option>QB</option> <option>WR</option> <option>RB</option> <option>TE</option> <option>PK</option> <option>DF</option> </select> </FORM> <div id="txtHint"> </div> </BODY> </html> Here is the java: var xmlHttpfunction ;showUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") } var url="getuser.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; } Here is what it is supposed to show: <?php $q=$_GET["q"]; require("db.php"); $sql="SELECT * FROM players WHERE position = '".$q."'"; $result = mysql_query($sql); ?> <html> <head> </head> <body> <form action="select.php" method="post"> Team name:<input type='text' name='name'><br> Password:<input type='password' name='pass'><br> Comment:<input type='text' name='com' maxlength='80'><br> <select name="playername"> <?php while($row = mysql_fetch_array($result)) { echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>"; } ?> </select> <input type="submit" name="submit" value="select"> </form> </body> </html> Any clues why I keep getting these errors. Link to comment Share on other sites More sharing options...
fenway Posted March 2, 2007 Share Posted March 2, 2007 Unless that's a cut and paste error, your showUser function is not properly declared. Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 2, 2007 Author Share Posted March 2, 2007 If youmean the ; I inserted it because firefox showed an error message saying it needed to be in there. I still get the same message as before without it. I just get an extra error saying I need to put it there. Link to comment Share on other sites More sharing options...
fenway Posted March 4, 2007 Share Posted March 4, 2007 You need to have the word "function" before the function name; the semi-colon goes after the var declaration. Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Author Share Posted March 5, 2007 I got all of the showuser stuff figured out. Turns out it's only a problem in IE works perfect and no errors in Firefox. Do I need to put the following at the top right below the var: 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; } Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 If it works, then yes. Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Author Share Posted March 5, 2007 Didn't work and sorry bout the repost it still won't work in IE. I been banging on this for days trying everything. Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 What do you mean by "not work"? It does get into the right control path, correct? Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Author Share Posted March 5, 2007 Again sorry for the double post this is in regards to my other question you're trying to help me with. Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 See this thread for the continuation. Link to comment Share on other sites More sharing options...
Recommended Posts