我有一个将完成两个操作的 asp 表单。第一个是将数据提交到数据库,第二个是将数据通过电子邮件发送给表单中选择的人。
我有一个下拉菜单,显示员工姓名并传递员工电子邮件地址的值。
我目前正在使用此 Jquery 代码将员工姓名传递给隐藏字段,并希望使用该隐藏字段提交到数据库。
$(document).ready( function (){
$("#to").change( function(){
var selectedValue = $("#to option:selected").val();
var selectedText = $("#to option:selected").text();
$("#hiddenText").val( selectedText );
alert("Hidden field text is: " + $("#hiddenText").val());
});
});
这似乎有效,警报显示正确的值。当我尝试提交表单并插入数据库时,我收到此错误:Microsoft OLE DB Provider for ODBC Drivers error '80040e57' [Microsoft][ODBC Microsoft Access Driver]Invalid string or buffer length /intranet/EmployeeInfo/Heroes1/ heropost.asp,第 30 行
下面是插入代码:
<%
If (CStr(Request("MM_insert")) = "heroes") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_PhoneDir_STRING
MM_editCmd.CommandText = "INSERT INTO REACH ([To], Dept, prideSelect, flagpoleSelect, [comment], [from]) VALUES (?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 203, 1, 1073741823, Request.Form("hiddenText")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("dept")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, Request.Form("prideSelect")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("flagpoleSelect")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 203, 1, 1073741823, Request.Form("comment")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 100, Request.Form("from")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "HeroesThanks.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
如果我“忽略”隐藏字段并仅从下拉列表中提交值,则表单提交时不会出错,并且信息将添加到数据库中。
关于我需要更改以使其正常工作的任何想法?