views:

23

answers:

2

dear all, i'm getting this problem with firefox and not with IE.

In first combo, i'm getting roles:

<tr>
<td>Select Role:</td>
<td>
<select name="usrrole" onChange="showuser(this.value)">
    <option value=''>Please Select</option>
<?php
  $rle = "select * from role_table";
  $dorle = mysql_query($rle);
  while($data = mysql_fetch_array($dorle)){
  echo ("<option value=$data[roleid]>$data[rolename]</option>");
}
?>
</select>
</td>
</tr>

<tr>
  <td> Select User </td>
  <td id="showus"> </td>  <!-- this is the div collected from ajax -->
</tr>
<tr>
  <td colspan=2> <input type='submit' name='submit' /> </td>
</tr>

(((( AJAX.JS ))))

function GetXmlHttpObject()
{
 var xmlHttp=null;
 try
  {
      xmlHttp=new XMLHttpRequest();
  }
 catch (e)
  {
      try
       {
           xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
       }
      catch (e)
       {
           xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
       }
   }
 return xmlHttp;
 }

function showusrinfo()
{
if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
 {
  document.getElementById('showus').innerHTML=xmlhttp.responseText;
 }
}

function showuser(str)
{
  xmlhttp=GetXmlHttpObject();
  var url="../get.php";
  url=url+"?showus="+str;    
  xmlhttp.onreadystatechange=showusrinfo; 
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null); 
}

(((( GET.PHP ))))

if(isset($_GET["showus"])){
$q  = $_GET["showus"];
$sql = "select uid,username from usertable where roleid='".$q."'";
$qry = mysql_query($sql);
$num = mysql_num_rows($qry);
if($num){
  $my = "<select name='touser'>";
  $my .= "<option selected value=''>Please Select</option>";
   while($result = mysql_fetch_array($qry)){
      $my .= "<option value='".$result['uid']."'>$result[username]</option>";
}
echo $my;
}
 else
{
 $notmy = "No Record";
}
echo $notmy;
}

Now, the problem arises when I Submit it:

if i print the variables after submit, then

in INTERNET EXPLORER:

Array
(
  [usrrole] => 1
  [touser] => 3
  [submit] => submit
)

and in FIREFOX:

Array
(
 [usrrole] => 1
 [submit] => submit
)

As you can see, the variable generated in AJAX is only shown in IE and not in FF, therefore, there is an error running the code in FF.

I'm a newbie in programming and stuck in it, please help.

cheers.

A: 

You should read selected option value, not select value

onChange="showuser(this.options[this.selectedIndex])"
Feeloow
No, the showuser should get a roleID, not the roleName: `showuser(this.value)` -> `url=url+"?showus="+str;` -> `$q = $_GET["showus"];` -> `...roleid='".$q."'";`
Lekensteyn
Note: I'm able to use ajax in FF, but can't reproduce POST values.
deepak
A: 

yes, that's right, i need the output in terms of roleID and not by name

dEePaK
awaiting a quick answer.. my program is held up till then.
dEePaK