Jump to content

[SOLVED] Why won't the value of q get passed in IE?


Greaser9780

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.