Greaser9780 Posted March 5, 2007 Share Posted March 5, 2007 var xmlHttp 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; } function showUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="showUser.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 } } No prob in firefox. In IE it shows the object (a second dropdown) but without the value of q the next query won't work. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 Q is never declared nor passed. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Author Share Posted March 5, 2007 url=url+"?q="+str Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 url=url+"?q="+str That is not a declaration; and it just magically appears. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Author Share Posted March 5, 2007 Well I can't understand why in firefox value of q gets passed from the first dropdown to the second. The first dropdown has six items q would be the value of that. When that gets past to the second dropdown a query uses q to determine what to display in the next dropdown. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 I never see q as an lvalue. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 5, 2007 Author Share Posted March 5, 2007 Would you like to see the 3 scripts? Maybe you could explain it to me. I am very green with java/ajax Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 What I'd like to see is the line where you assign the value of q. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 6, 2007 Author Share Posted March 6, 2007 First select page: <html> <head> <script src="selectuser.js"></script> </head> <body> <div align="center"> <form> <select name="users" onchange="showUser(this.value)"> <option>QB <option>WR <option>RB <option>TE <option>K <option>DF </select> </form> </div> <div id="txtHint"> </div> </BODY> </html> You already have the .js script And here is the second dropdown page: <?php $q=$_GET['q']; include("db.php"); $sql="SELECT name FROM players WHERE position='".$q."' ORDER BY name ASC"; $result = mysql_query($sql); ?> <html> <head> </head> <body> <form action="select.php" method="post"> 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> I thought the showuser function used at onchange sent (this.value) to the .js file as the (str) in the function description and was included with the url as url=url+"?q="+str . So I figured the value of q was equal to the choice that the user made. If I am wrong in this please chow me where I went wrong and give an opinion of how to fix it. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 7, 2007 Share Posted March 7, 2007 OK, that makes sense, I was confused about q because it was both a variable and a string literal. Are you sure that if you alert the url variable after the assignment it's different in the two browsers? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 8, 2007 Author Share Posted March 8, 2007 The problem I can see is that in IE the value of q is not read by the next script. It doesn't make sense to me as to why it won't. I currently get no object type of error. The only error I do get is a small error symbol at the bottom of my browser. A little yellow ! in a triangle. I ran it in firefox. It works and I get no errors in the console other than css errors and that's only due to where the files currently reside. I can't even echo $q in IE so I know the problem is that IE won't get the value. It does however display the next dropbox like it's supposed to. It's just empty because I use $q to pull data with a query. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 8, 2007 Share Posted March 8, 2007 Like I said, put an alert after you assign the url variable. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 8, 2007 Author Share Posted March 8, 2007 such as alert("at least this is getting through"); Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 8, 2007 Author Share Posted March 8, 2007 The alert comes through fine. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 8, 2007 Share Posted March 8, 2007 no, such as alert(url) Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 9, 2007 Author Share Posted March 9, 2007 I get alert showUser.php?q=. If I put quotes around the +str the alert shows showUser.php?q=str When I do the same in firefox with the alert I get showUser.php?q=RB or whichever I choose. It's like the showUser function doesn't work properly in IE Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 9, 2007 Author Share Posted March 9, 2007 It works in netscape as well with no errors. I tried an alert to show the object. I get the same in netscape and firefox XMLHttpRequest as object. But when I run it in IE I just get "object". Is it possibly my browser settings? Quote Link to comment Share on other sites More sharing options...
fenway Posted March 9, 2007 Share Posted March 9, 2007 I get alert showUser.php?q=. If I put quotes around the +str the alert shows showUser.php?q=str When I do the same in firefox with the alert I get showUser.php?q=RB or whichever I choose. It's like the showUser function doesn't work properly in IE Well, that sounds like str doesn't contain anything... probably because your option tags don't have value attributes!!! You want: <option value="RB">RB</option> Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 9, 2007 Author Share Posted March 9, 2007 Fenway, You are the Fn man. Wow do I feel alot better now. And as usual, it's always the simple things that screw something up for me.THX for putting up with my incessant cries to get this figured out. I can't believe it even ran like it did in FF. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 9, 2007 Share Posted March 9, 2007 Yeah, I've run into similar issues with FF "making up" attributes as it goes along... often, IE is guilty of this, but it won't give you a value is there's no value... imagine that. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 9, 2007 Author Share Posted March 9, 2007 It's kind of ironic. In my second dropdown I list a value for each one. I changed everything I could think of on the first one except for that. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 9, 2007 Share Posted March 9, 2007 Yup, it happens...explicit is always better. 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.