Jump to content

ajax not supporting firefox and mozilla


fareedreg

Recommended Posts

I m working on library managment system ... i m getting value from database using ajax on bookid basis. my code is working perfectly in ie6 and above ... but not getting result on firefox and opera latest version... WHY?

 

 

 

code php

 

<select name="cmbsuppid" id="cmbissueid" onchange="showSupplier(this.value);">

   

    <?php

 

    include('connect.php');

 

    $Tb = "booksupp_master";

 

    mysql_select_db($Db, $link);

                           

    $query = "select supp_id from $Tb order by supp_id";

 

    $result= mysql_query($query,$link);

 

    $fel=mysql_num_fields($result);

    $nro=mysql_num_rows($result);

 

    if ($nro>0)

 

    {

   

       

        echo "<option>-- Select Supplier --</option>\n";   

       

    while ($row=mysql_fetch_array($result))

 

        {

   

            echo "<option value='$row[supp_id]'>$row[supp_id]</option>\n";

       

        }                       

                             

    }

 

    mysql_close($link);

 

  ?>

 

  </select> 

 

  </tr>

   

    <tr>

    <td>Supplier Name </td>

    <td>

    <div name="txtSupp" id="txtSupp"><b></b></div>    </td>

    </tr>

 

 

 

 

 

 

 

 

 

ajax

 

var xmlhttp;

 

function showBook(str)

{

xmlhttp=GetXmlHttpObject();

if (xmlhttp==null)

  {

  alert ("Browser does not support HTTP Request");

  return;

  }

var url="getbookname.php";

url=url+"?q="+str;

url=url+"&sid="+Math.random();

xmlhttp.onreadystatechange=stateChangedbook;

xmlhttp.open("GET",url,true);

xmlhttp.send(null);

}

 

function stateChangedbook()

 

{

if (xmlhttp.readyState==4)

{

    document.getElementById("txtbook").innerHTML=xmlhttp.responseText;

}

}

 

function GetXmlHttpObject()

{

if (window.XMLHttpRequest)

  {

  // code for IE7+, Firefox, Chrome, Opera, Safari

  return new XMLHttpRequest();

  }

if (window.ActiveXObject)

  {

  // code for IE6, IE5

  return new ActiveXObject("Microsoft.XMLHTTP");

  }

return null;

}

 

 

 

 

 

 

 

 

getbookname.php

 

<?php

 

session_start();

 

$q=$_GET["q"];

 

include ('connect.php');

 

mysql_select_db($Db, $link);     

 

$query="select * from book_master where book_id=$q";

 

$result= mysql_query($query,$link) or die(""); 

 

$fel=mysql_num_fields($result);

$nro=mysql_num_rows($result);

 

 

if($nro>0)

{

       

    $row=mysql_fetch_array($result);

 

    echo "<td>" . $row['book_name'] . "</td>";

    echo "&nbsp";

    echo "&nbsp";

    echo "&nbsp";

    echo "&nbsp";

   

    echo "Book Price : ";

    $bookprice=$row['cost'];

    echo "<td>" . $row['cost'] ."</td>";

    echo "&nbsp";

    echo "&nbsp";

    echo "&nbsp";

    echo "&nbsp";

   

   

    echo "Status : ";

   

    $status = $row['avail'];

 

    if ($status==0)

   

    {

       

            echo  "<td>" . "Book Available" . "</td>";

    }

   

    if ($status==1)

   

    {

            echo  "<td>" . "Book is Not Available" . "</td>"; 

   

    }

}

 

 

 

////Param percentage

 

$query="select issuecharges,noofdays from param";

 

$result= mysql_query($query,$link) or die(""); 

 

$fel=mysql_num_fields($result);

$nro=mysql_num_rows($result);

 

if($nro>0)

 

{

     

    $row=mysql_fetch_array($result);

   

    $perval=$row['issuecharges'];

   

   

}

 

$cal = $bookprice/100*$perval;

 

$_SESSION['charge'] = $cal;

 

echo "<br>";

echo "<td height='21'>Issue Charges :<b> $cal </b></td>";

 

echo "&nbsp";

echo "&nbsp";

echo "<b>rupees<b>";

mysql_close($link);

 

 

?>

Link to comment
Share on other sites

Try this: In your javascript code:

window.onload = initPage;
function initPage() {
  document.getElementById("cmbissueid").onBlur = showSupplier(document.getElementById("cmbissueid").value);
}

 

Then remove:

onchange="showSupplier(this.value);"

 

from the html code

 

Hope that helps,

Richard

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.