【发布时间】:2016-12-08 16:30:16
【问题描述】:
在 Chrome 中单击按钮不会触发 javascript 函数(InsertRecord()),但在 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!");
}
}
你能告诉我这里的问题吗?
谢谢,
【问题讨论】:
-
您好 Angelos,您能告诉我如何在 Chrome 中运行它吗?
-
检查我更新的答案,我想我已经找到了一种方法来解决您的问题,而无需更改任何现有代码。
-
如果您发现任何答案有帮助,请记得点赞并接受最能帮助您解决问题的答案!
标签: javascript html google-chrome internet-explorer