Reputation: 143
Button click not triggering javascript function(InsertRecord()) in Chrome but working fine in IE.
<input id="submit" type="button" value="Request Access" onclick="InsertRecord()" style="width:160px;"/>
function InsertRecord()
{
var txtUserName = document.getElementById('txtUserName').value;
var txtDept = document.getElementById('ddlDept').value;
var txtClass = document.getElementById('txtClass').value;
var txtRole = document.getElementById('ddlRole').value;
var txtAccess = document.getElementById('ddlAccess').value;
if (txtUserName.length != 0 || txtDept.length != 0 || txtClass.length !=0 || txtRole.length !=0 || txtAccess.length !=0)
{
var connection = new ActiveXObject("ADODB.Connection");
var connectionstring = "Data Source=dvuksdcwsql001;Initial Catalog=RP_5500_AppDB;Persist Security Info=True;User ID=CPT_DEV;Password=Cpt%100@123;Provider=SQLOLEDB";
connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open("insert into Range_Plan_Access values('" + txtUserName + "','" + txtDept + "','" + txtClass + "','" + txtRole + "','" + txtAccess + "')", connection);
alert("Access Requested Successfully!");
connection.close();
}
else
{
alert("Please enter a value for User Name \n Department \n Class \n Role \n Access Required!");
}
}
Could you please let me know the issue here?
Thanks,
Upvotes: 2
Views: 344
Reputation: 6747
The issue lies with the ActiveXObject()
calls as they are only supported in IE. Chrome uses a different plugin architecture called NPAPI. There is a cross-browser plugin framework, Firebreath, that might be of use to you.
UPDATE: After searching around a bit, I also found this discussion on the Google Chrome Help Forum, which states that IE Tab for Google Chrome might allow your existing code to run properly. Give it a shot!
Upvotes: 1
Reputation: 1009
ActiveX is supported only in IE.
I think you have to avoid this use, because you are exposing your Database in client side, so anyone can manipulate your DB.
It is jut my opinion. Avoid to use ActiveX to do this work.
Create a webservice to do this work.
Hope it help you.
Upvotes: 1
Reputation: 21638
Chrome does not support ActiveX. You shouldn't be connecting to a database through the browser, you should have a serverside API that connects to the database. What you are trying to do is bad mkay!
Upvotes: 0