views:

352

answers:

3

My program is getting employee details in web page using javascript. This is successfully working in IE5,6,8. but not working Mozilla Firefox. Please Help me...

Thanks in advance

My source code is:


<script type="text/javascript">
<!--
var adOpenDynamic = 2;
var adLockOptimistic = 3;

/* Path of database.
*/
var strDbPath = "..\\SRVGdb.mdb";

/*
Here is the ConnectionString for Microsoft Access.
If you want to use SQL or other databases, you hav to change the connection string..
eg: SQL => var conn_str = "Provider=sqloledb; Data Source=itdev; Initial Catalog=pubs; User ID=sa;Password=yourpassword";
*/
var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbPath;

function getAdoDb(strAdoType){
if (window.ActiveXObject){
return new ActiveXObject(strAdoType);
}
else{
return ActiveXObject(strAdoType);
}
}

function showReports(){
try{
var tablevar="<table width=\"100%\" border=\"1\">"
                    +"  <tr><td></td>"
                    +"  </tr>";

//Database Connection
var conn = getAdoDb("ADODB.Connection");
conn.open(conn_str, "", "");

//Recordset
var rs = new ActiveXObject("ADODB.Recordset");
strQuery = "SELECT * FROM GuestBook";
rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);

if(!rs.bof){
rs.MoveFirst();

while(!rs.eof) {

    if(document.layers){
     document.getElementById("one").open();

     document.getElementById("one").close();
    }
    else{

tablevar+="  <tr>"
                    +"    <td>"+"Sur Name: <br> Fore Name: <br> Home Address: <br> PinCode: <br> Contact Number: <br> E-mail: <br> Date of Birth: <br>  Nationality: <br> University: <br> Available Timings: <br> Interested Courses: <br> Other Courses:  <br> Expected Money:  <br> Any More Information: <br> "+"</td>"
                    +"    <td>"+rs.fields(0).value+"<br>"+rs.fields(1).value+"<br>"+rs.fields(2).value+"<br>"+rs.fields(3).value+"<br>"+rs.fields(4).value+"<br>"+rs.fields(5).value+"<br>"+rs.fields(6).value+"<br>"+rs.fields(7).value+"<br>"+rs.fields(8).value+"<br>"+rs.fields(9).value+"<br>"+rs.fields(10).value+"<br>"+rs.fields(11).value+"<br>"+rs.fields(12).value+"<br>"+rs.fields(13).value+"<br></td>"
      +"  </tr>";

    document.getElementById("one").innerHTML=tablevar;

}

    rs.MoveNext();
    }
}
else{

    if(document.layers){
     document.getElementById("one").open();

     document.getElementById("one").close();
    }
    else{

     document.all("one").innerHTML="No Records To Display.";

    }
//No Records.

}
conn.close();


tablevar+= "</table>";

}catch(ex){
alert(ex.message);
}
}

//-->
</script>
+1  A: 

ActiveX objects are proprietary to Internet Explorer. You'd have to find the equivalent object to perform the same functionality in other browsers, if there is one. You'd have to show what you're doing exactly to be any more specific in how to get it to work.

Zurahn
A: 

Assuming you are referring to Ajax, Use an abstracted XHR function that supports XMLHttpRequest and the IE specific ActiveX objects.

/** XHConn - Simple XMLHTTP Interface - [email protected] - 2005-04-08        **
 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/
function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}


/* assuming you already have XHConn.js included in your HTML file */

var myConn = new XHConn();

if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

var fnWhenDone = function (oXML) { alert(oXML.responseText); };

myConn.connect("mypage.php", "POST", "foo=bar&baz=qux", fnWhenDone);
meder
A: 

There's no ActiveX support in Firefox and no way to connect to an Access database. These are proprietary Microsoft technologies.

I do not believe there is browser-side ODBC support either; I could be wrong about this point.

Broam