按鈕點擊不觸發JavaScript功能(InsertRecord())在Chrome中,但在IE中工作正常。按鈕點擊不觸發在Chrome瀏覽器的JavaScript功能,但在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%[email protected];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!");
}
}
您能否讓我知道這裏的問題?
感謝,
嗨安吉洛斯,你可以讓我知道我怎麼才能得到它在Chrome甚至工作? – Emraan
檢查我更新的答案,我想我已經找到了一種方法來解決您的問題,而無需更改任何現有的代碼。 –
如果您發現任何有用的答案,請記住加入他們並接受幫助您解決您的問題最多的答案! –