Jump to content

showuser not defined???


Greaser9780

Recommended Posts

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

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

Guest
This topic is now closed to further replies.
×
×
  • 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.