Forums
This topic is locked
Multi-Insert Form??...Pls Help:(
Posted 29 Apr 2003 21:19:25
1
has voted
29 Apr 2003 21:19:25 Katherine Williams posted:
I went to a page on DMXZone named "Multiple delete using Javascript " at dmxzone.com/ShowDetail.asp?NewsId=3430, and I thought I could somehow change it to an Insert to do what I need...a page that inserts multiple records from one form into one table. My plan is to get the Delete Behavior to work first using the script from that page, then I was going to change it to an Insert page.But I'm getting an error message (see below). I've also included the page's code, and the query that's generated upon submittal. If someone can help me out with this, or point me in the right direction, it would be greatly appreciated. If anyone knows of a working script or extension (no demos) that I can get a hold of that will do a multiple insert from one form into one DB table, please let me know. Thanks in advance.
KWilliams
I'm getting this error message:
>Microsoft OLE DB Provider for SQL Server error '80040e14'
>Line 1: Incorrect syntax near '(03-005 )'.
>/Employment/app_jobs3C.asp, line 28
This is the query that's generated upon submittal of the form:
>www.douglas-county.com/Employment/app_jobs3C.asp?checkbox=03-005++++&Submit=Add+Job%28s%29[/Q]
And finally, this is the page's code using the JavaScript from DMXZone's page referenced above:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<%
if(String(Request.Querystring("checkbox"



%>
<%
// Script enabling multiple delete of records
// If there is no choice, the page "app_jobsconf.asp" is loaded again
// and a message box alerts the user
var emptystring=String(Request.Querystring("checkbox"

if (emptystring !="undefined"

var parenthesisin="("; //var containing the string "("
var parenthesisout="


//Var "parenthesisin" and "parenthesisout" are added before and after the var "String(Request.Querystring("checkbox"

if (String(Request.Querystring("checkbox"



var Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_strConn_STRING;
// Create a command in "Data Bindings", type="DELETE", SQL="DELETE * FROM Employ_Jobs WHERE Job_ID IN Command1__varJob_ID"
// varJob_ID is a var which value is "Request.Querystring("checkbox"

var Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_strConn_STRING;
Command1.CommandText = "DELETE FROM dbo.Employ_Jobs WHERE Job_ID IN '"+ Command1__varJob_ID.replace(/'/g, "''"

Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
Response.Redirect("app_jobsconf.asp"

}
else {%>
<%
var rs_App1A__MMColParam = "Seqno";
if(String(Request.QueryString("id"


rs_App1A__MMColParam = String(Request.QueryString("id"

}
%>
<%
var rs_App1A__varApp_ID = "%";
if(String(Session("App_ID"


rs_App1A__varApp_ID = String(Session("App_ID"

}
%>
<%
var rs_App1A__varPassword = "%";
if(String(Session("Password"


rs_App1A__varPassword = String(Session("Password"

}
%>
<%
var rs_App1A = Server.CreateObject("ADODB.Recordset"

rs_App1A.ActiveConnection = MM_strConn_STRING;
rs_App1A.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rs_App1A__varApp_ID.replace(/'/g, "''"



<% var rs_App1B = Server.CreateObject("ADODB.Recordset"

rs_App1B.ActiveConnection = MM_strConn_STRING;
rs_App1B.Source = "SELECT * FROM Jobs WHERE Job_ID IN (SELECT Job_ID FROM Employ_Jobs) ORDER BY Job_Title ASC"; rs_App1B.CursorType = 0; rs_App1B.CursorLocation = 2; rs_App1B.LockType = 3; rs_App1B.Open(); var rs_App1B_numRows = 0; %>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
rs_App1B_numRows += Repeat1__numRows;
%>
<% if (rs_App1A.EOF) Response.Redirect("www.douglas-county.com/Employment/noaccess.asp")%>
<%
Session("Seqno"


Session("App_ID"


Session("Password"


%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index="; if (MM_paramName != ""

MM_paramName.toLowerCase() + "=";
var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd();
items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd();
items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings MM_keepBoth = MM_keepURL + MM_keepForm; if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1); if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1); if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1); %>
<html>
<head>
<title>Douglas County, Kansas - Online Employment Application-Step 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="keywords" CONTENT="Douglas County,Douglas County KS,Douglas County Kansas,Douglas,County,Kansas,Government,KS Government,Kansas Government,Stephen A. Douglas,Quantrill,Quantrill's Raid,Lawrence,Lecompton,Baldwin,Baldwin
City,Eudora,Clinton,Jayhawks;KU,Kansas University,University of Kansas,University of KS,Baker University,Haskell,Haskell Indian Nations University,John Baldwin,Amos A. Lawrence,Samuel D. Lecompte,Kanzas Nation.">
<META NAME="description" CONTENT= "Official site for Douglas County, Kansas - Our mission is to provide for the safety and well being of the citizens of Douglas County through the professional and efficient delivery of essential public services in response to the needs of Douglas County citizens.">
<style type="text/css">
<!--
.roll { font-family:"Arial, Helvetica, sans-serif" size="1"; font-style:normal; font-weight:normal; letter-spacing:normal; text-decoration:underline; color:330066; }
A.roll:hover { size="1"; color:red; text-decoration:none;}
-->
INPUT, TEXTAREA {
font-family: "Arial, Helvetica, sans-serif";
padding: 1px;
font-size: 12px;
color: #000000;
background-color: #FFFFFF;
border: inset 2px #660000;
}
</style>
<script language="JavaScript">
<!--
<!-- Begin
if (window != top) top.location.href = location.href;
function NewWindow(mypage, myname, w, h, scroll)
{
var winl = (screen.width - w) / 1.5;
var wint = (screen.height - h) / 1.65;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll
+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
var isNN = (navigator.appName.indexOf("Netscape"

function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1">
<table width="660" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC">
<tr>
<td valign="top" height="2">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="2" bgcolor="#660000"><font size="2" face="Arial, Helvetica, sans-serif" color="#FFFFFF"><b>Position(s) applying for:</b></font></td>
</tr>
<tr bgcolor="#FFFFCC" valign="top">
<td colspan="2" height="37">
<div align="left">
<% while ((Repeat1__numRows-- != 0) && (!rs_App1B.EOF)) { %>
<input type="checkbox" name="checkbox" value="<%=(rs_App1B.Fields.Item("Job_ID"

<font size="2" face="Arial, Helvetica, sans-serif"><%=(rs_App1B.Fields.Item("Job_Title"


<%
Repeat1__index++;
rs_App1B.MoveNext();
}
%>
</div>
</td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2">
<p><font size="1" face="Arial, Helvetica, sans-serif" color="#FF0000"><b><img src="Images/bullet2.gif" width="8" height="8">To view details for each position, visit the'View Details' links above.
</b></font>
</p>
</td>
</tr>
<tr>
<td bgcolor="#FFFFCC" valign="bottom" height="2" width="66%"><font size="2" face="Arial, Helvetica, sans-serif">If you have any questions about this form, please contact the Douglas County <a class=roll href=" webmaster <mailto: >
.mailto: ">webmaster</a>.</font></td>
<td bgcolor="#FFFFCC" valign="top" height="2" width="34%" colspan="-1">
<div align="right">
<input type="button" name="Submit2" value="Cancel" onClick="window.close()">
<input type="submit" name="Submit" value="Add Job(s)">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<%
rs_App1A.Close();
%>
<%
rs_App1B.Close();
%>
<%
}%>
Replies
Replied 02 May 2003 17:57:59
02 May 2003 17:57:59 Katherine Williams replied:
Hi,
I didn't receive one response to my last post, but I have made some progress using some tutorials from DMXZone.com. I'm trying to create an Insert page that allows a user to insert one or more job selections into a DB table (SQL). I've looked through your tutorial, and others as well to get some ideas. I think I'm very close to a solution, but I'm missing something.
The problem is that when a user selects more than one job, the page enters the data into one row in the DB table instead of adding each job selection into separate rows (which is what I want it to do). There are 3 table columns in the DB table named dbo.Employ_jobs: Job_ID, App_ID, and Creation_Date. The data comes from a DB table named dbo.Jobs. The App_ID comes from a Session Variable, but the other 2 come from form data from the first page.
I'm not sure what I'm doing wrong, but I'm hoping that SOMEONE can PLEASE help me out, or point me in the right direction to someone that can. I'd really appreciate ANY help. I've included the code for the 2 pages below.
Katherine Williams
FORM PAGE (app_jobs3D.asp):
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<%
var rs_App1A__MMColParam = "Seqno";
if(String(Request.QueryString("id"
) != "undefined"
{
rs_App1A__MMColParam = String(Request.QueryString("id"
);
}
%>
<%
var rs_App1A__varApp_ID = "%";
if(String(Session("App_ID"
) != "undefined"
{
rs_App1A__varApp_ID = String(Session("App_ID"
);
}
%>
<%
var rs_App1A__varPassword = "%";
if(String(Session("Password"
) != "undefined"
{
rs_App1A__varPassword = String(Session("Password"
);
}
%>
<%
var rs_App1A = Server.CreateObject("ADODB.Recordset"
;
rs_App1A.ActiveConnection = MM_strConn_STRING;
rs_App1A.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rs_App1A__varApp_ID.replace(/'/g, "''"
+ "' AND Password LIKE '"+ rs_App1A__varPassword.replace(/'/g, "''"
+ "' AND Seqno = "+ rs_App1A__MMColParam.replace(/'/g, "''"
+ "";
rs_App1A.CursorType = 0;
rs_App1A.CursorLocation = 2;
rs_App1A.LockType = 3;
rs_App1A.Open();
var rs_App1A_numRows = 0;
%>
<%
var rs_App1B = Server.CreateObject("ADODB.Recordset"
;
rs_App1B.ActiveConnection = MM_strConn_STRING;
rs_App1B.Source = "SELECT * FROM Jobs WHERE Job_ID NOT IN (SELECT Job_ID FROM Employ_Jobs) AND GetDate() BETWEEN Post_Startdate AND Post_Enddate ORDER BY Job_Title ASC";
rs_App1B.CursorType = 0;
rs_App1B.CursorLocation = 2;
rs_App1B.LockType = 3;
rs_App1B.Open();
var rs_App1B_numRows = 0;
%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != ""
MM_removeList += "&" + MM_paramName.toLowerCase() + "=";
var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<%
var HLooper1__numRows = -3;
var HLooper1__index = 0;
rs_App1B_numRows += HLooper1__numRows;
%>
<% if (rs_App1A.EOF) Response.Redirect("www.douglas-county.com/Employment/noaccess.asp"); %>
<%
Session("Seqno"
= rs_App1A.Fields.Item("Seqno"
.Value
Session("App_ID"
= rs_App1A.Fields.Item("App_ID"
.Value
Session("Password"
= rs_App1A.Fields.Item("Password"
.Value
Session("Job_ID"
= rs_App1B.Fields.Item("Job_ID"
.Value
%>
<html>
<head>
<title>Douglas County, Kansas - Online Employment Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="keywords" CONTENT="Douglas County,Douglas County KS,Douglas County Kansas,Douglas,County,Kansas,Government,KS Government,Kansas Government,Stephen A. Douglas,Quantrill,Quantrill's Raid,Lawrence,Lecompton,Baldwin,Baldwin City,Eudora,Clinton,Jayhawks;KU,Kansas University,University of Kansas,University of KS,Baker University,Haskell,Haskell Indian Nations University,John Baldwin,Amos A. Lawrence,Samuel D. Lecompte,Kanzas Nation.">
<META NAME="description" CONTENT= "Official site for Douglas County, Kansas - Our mission is to provide for the safety and well being of the citizens of Douglas County through the professional and efficient delivery of essential public services in response to the needs of Douglas County citizens.">
<style type="text/css">
<!--
.roll { font-family:"Arial, Helvetica, sans-serif" size="1"; font-style:normal; font-weight:normal; letter-spacing:normal; text-decoration:underline; color:330066; }
A.roll:hover { size="1"; color:red; text-decoration:none;}
-->
INPUT, TEXTAREA {
font-family: "Arial, Helvetica, sans-serif";
padding: 1px;
font-size: 12px;
color: #000000;
background-color: #FFFFFF;
border: inset 2px #660000;
}
</style>
<script language="JavaScript">
<!--
<!-- Begin
if (window != top) top.location.href = location.href;
function NewWindow(mypage, myname, w, h, scroll)
{
var winl = (screen.width - w) / 1.5;
var wint = (screen.height - h) / 1.65;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
var isNN = (navigator.appName.indexOf("Netscape"
!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="660" border="0" align="left">
<tr>
<td valign="top" height="123" colspan="2">
<form name="form1" method="post" action="app_jobs3D2.asp">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC">
<tr>
<td valign="top" height="2">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="3" bgcolor="#660000"><font size="2" face="Arial, Helvetica, sans-serif" color="#FFFFFF"><b>Position(s) applying for:</b></font></td>
</tr>
<tr bgcolor="#FFFFCC" valign="top">
<td colspan="3" height="37">
<div align="left">
<%
var startrw=0;
var endrw=HLooper1__index;
var numberColumns=3;
var numrows=-1;
while((numrows-- !=0) && (!rs_App1B.EOF)) {
startrw=endrw + 1;
endrw = endrw + numberColumns;
%>
<%
while ((startrw <= endrw) && (!rs_App1B.EOF)) {
%>
<input <%=((rs_App1B.Fields.Item("Job_ID"
.Value == 0)?"CHECKED":""
%> type="checkbox" name="checkbox" value="<%=(rs_App1B.Fields.Item("Job_ID"
.Value)%>">
<font size="2" face="Arial, Helvetica, sans-serif"><%=(rs_App1B.Fields.Item("Job_Title"
.Value)%><a class=roll href="app_jobdesc.asp?<%=("Job_ID=" + rs_App1B.Fields.Item("Job_ID"
.Value) %>" target="_blank" onClick="NewWindow(this.href,'name','700','300','yes');return false;"><font size="1">View Details</font></a><br>
</font>
<input type="hidden" name="hiddenField" value="<%Response.Write(Date())%>">
<input type="hidden" name="hiddenField2" value="<%=Session("App_ID"
%>">
<input type="hidden" name="MM_insert" value="true">
<%
startrw = startrw+1;
rs_App1B.MoveNext();
}
%>
<% }%>
</div>
</td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="3">
<p><font size="1" face="Arial, Helvetica, sans-serif" color="#FF0000"><b><img src="Images/bullet2.gif" width="8" height="8">To view details for each position, click on the 'View Details' links above.
</b></font>
</p>
</td>
</tr>
<tr>
<td bgcolor="#FFFFCC" valign="bottom" height="34" width="71%"><font size="2" face="Arial, Helvetica, sans-serif">If you have any questions about this form, please contact the Douglas County <a class=roll href="mailto: ">webmaster</a>.</font></td>
<td bgcolor="#FFFFCC" valign="bottom" height="34">
<div align="right">
<input type="hidden" name="hiddenField3" value="<%=Session("Password"
%>">
<a class=roll href="javascript:window.close()">
</a><a class=roll href="">
<input type="button" name="Button2" value="Cancel" onClick="window.close()">
</a>
<input type="submit" name="Submit" value="Add Job(s)">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<%
rs_App1A.Close();
%>
<%
rs_App1B.Close();
%>
INSERT PAGE (app_jobs3D2.asp:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<%
if(String(Request.Form("checkbox"
) != "undefined"
{ Command1__varJob_ID = String(Request.Form("checkbox"
);}
if(String(Session("App_ID"
) != "undefined"
{ Command1__varApp_ID = String(Session("App_ID"
);}
if(String(Request.Form("hiddenField"
) != "undefined"
{ Command1__varCreation_Date = String(Request.Form("hiddenField"
);}
%>
<%
var rs_App1A__MMColParam = "Seqno";
if(String(Request.QueryString("id"
) != "undefined"
{
rs_App1A__MMColParam = String(Request.QueryString("id"
);
}
%>
<%
var rs_App1A__varApp_ID = "%";
if(String(Session("App_ID"
) != "undefined"
{
rs_App1A__varApp_ID = String(Session("App_ID"
);
}
%>
<%
var rs_App1A__varPassword = "%";
if(String(Session("Password"
) != "undefined"
{
rs_App1A__varPassword = String(Session("Password"
);
}
%>
<%
var rs_App1A = Server.CreateObject("ADODB.Recordset"
;
rs_App1A.ActiveConnection = MM_strConn_STRING;
rs_App1A.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rs_App1A__varApp_ID.replace(/'/g, "''"
+ "' AND Password LIKE '"+ rs_App1A__varPassword.replace(/'/g, "''"
+ "' AND Seqno = "+ rs_App1A__MMColParam.replace(/'/g, "''"
+ "";
rs_App1A.CursorType = 0;
rs_App1A.CursorLocation = 2;
rs_App1A.LockType = 3;
rs_App1A.Open();
var rs_App1A_numRows = 0;
%>
<%
var rs_App1B = Server.CreateObject("ADODB.Recordset"
;
rs_App1B.ActiveConnection = MM_strConn_STRING;
rs_App1B.Source = "SELECT * FROM Jobs WHERE Job_ID NOT IN (SELECT Job_ID FROM Employ_Jobs) AND GetDate() BETWEEN Post_Startdate AND Post_Enddate ORDER BY Job_Title ASC";
rs_App1B.CursorType = 0;
rs_App1B.CursorLocation = 2;
rs_App1B.LockType = 3;
rs_App1B.Open();
var rs_App1B_numRows = 0;
%>
<%
var HLooper1__numRows = -3;
var HLooper1__index = 0;
rs_App1B_numRows += HLooper1__numRows;
%>
<% if (rs_App1A.EOF) Response.Redirect("www.douglas-county.com/Employment/noaccess.asp"); %>
<%
Session("Seqno"
= rs_App1A.Fields.Item("Seqno"
.Value
Session("App_ID"
= rs_App1A.Fields.Item("App_ID"
.Value
Session("Password"
= rs_App1A.Fields.Item("Password"
.Value
%>
<%
// *** Insert Record: set variables
if (String(Request("MM_insert"
) != "undefined"
{
var startrw=0;
var endrw=HLooper1__index;
var numberColumns=3;
var numrows=-1;
while((numrows-- !=0) && (!rs_App1B.EOF)) {
startrw=endrw + 1;
endrw = endrw + numberColumns;
%>
<%
while ((startrw <= endrw) && (!rs_App1B.EOF)) {
%>
<%
// Script enabling multiple delete of records
// If there is no choice, the page "app_jobs3D2.asp" is loaded again
// and a message box alerts the user
var varJob_ID=String(Request.Form("checkbox"
) // The var "varJob_ID" is used to check the "choice or no choice"
if (varJob_ID !="undefined"
{ // If the var "varJob_ID" contains the user's choice, the datas are deleted
var parenthesisin="("; //var containing the string "("
var parenthesisout="
"; //var containing the string "
"
//Var "parenthesisin" and "parenthesisout" are added before and after the var "String(Request.Form("checkbox"
)"
if (String(Request.Form("checkbox"
) != "undefined"
{ Command1__varJob_ID =parenthesisin + String(Request.Form("checkbox"
)+ parenthesisout;}
var Command1 = Server.CreateObject("ADODB.Command"
;
Command1.ActiveConnection = MM_strConn_STRING;
// Create a command in "Data Bindings", type="INSERT", SQL="INSERT INTO dbo.Employ_Jobs (Job_ID, App_ID, Creation_Date) VALUES"
// varJob_ID is a var which value is "Request.Form("checkbox"
"
Command1.CommandText = "INSERT INTO dbo.Employ_Jobs (Job_ID, App_ID, Creation_Date) VALUES ('"+ Command1__varJob_ID.replace(/'/g, "''"
+ "', '"+ Command1__varApp_ID.replace(/'/g, "''"
+ "', '"+ Command1__varCreation_Date.replace(/'/g, "''"
+ "') ";
Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
Response.Redirect("app_jobsconf.asp"
}
%>
<%
startrw = startrw+1;
rs_App1B.MoveNext();
}
%>
<% }%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != ""
MM_removeList += "&" + MM_paramName.toLowerCase() + "=";
var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><font size="2" face="Arial, Helvetica, sans-serif">
This form is submitting. You should be redirected to App_Main.asp soon!</font>
</p>
<p><font size="2" face="Arial, Helvetica, sans-serif">Response.Redirect("www.douglas-county.com/Employment/redirect_main.asp"<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle></font></p>
</body>
</html>
<%
rs_App1A.Close();
%>
<%
rs_App1B.Close();}
%>
I didn't receive one response to my last post, but I have made some progress using some tutorials from DMXZone.com. I'm trying to create an Insert page that allows a user to insert one or more job selections into a DB table (SQL). I've looked through your tutorial, and others as well to get some ideas. I think I'm very close to a solution, but I'm missing something.
The problem is that when a user selects more than one job, the page enters the data into one row in the DB table instead of adding each job selection into separate rows (which is what I want it to do). There are 3 table columns in the DB table named dbo.Employ_jobs: Job_ID, App_ID, and Creation_Date. The data comes from a DB table named dbo.Jobs. The App_ID comes from a Session Variable, but the other 2 come from form data from the first page.
I'm not sure what I'm doing wrong, but I'm hoping that SOMEONE can PLEASE help me out, or point me in the right direction to someone that can. I'd really appreciate ANY help. I've included the code for the 2 pages below.
Katherine Williams
FORM PAGE (app_jobs3D.asp):
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<%
var rs_App1A__MMColParam = "Seqno";
if(String(Request.QueryString("id"


rs_App1A__MMColParam = String(Request.QueryString("id"

}
%>
<%
var rs_App1A__varApp_ID = "%";
if(String(Session("App_ID"


rs_App1A__varApp_ID = String(Session("App_ID"

}
%>
<%
var rs_App1A__varPassword = "%";
if(String(Session("Password"


rs_App1A__varPassword = String(Session("Password"

}
%>
<%
var rs_App1A = Server.CreateObject("ADODB.Recordset"

rs_App1A.ActiveConnection = MM_strConn_STRING;
rs_App1A.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rs_App1A__varApp_ID.replace(/'/g, "''"



rs_App1A.CursorType = 0;
rs_App1A.CursorLocation = 2;
rs_App1A.LockType = 3;
rs_App1A.Open();
var rs_App1A_numRows = 0;
%>
<%
var rs_App1B = Server.CreateObject("ADODB.Recordset"

rs_App1B.ActiveConnection = MM_strConn_STRING;
rs_App1B.Source = "SELECT * FROM Jobs WHERE Job_ID NOT IN (SELECT Job_ID FROM Employ_Jobs) AND GetDate() BETWEEN Post_Startdate AND Post_Enddate ORDER BY Job_Title ASC";
rs_App1B.CursorType = 0;
rs_App1B.CursorLocation = 2;
rs_App1B.LockType = 3;
rs_App1B.Open();
var rs_App1B_numRows = 0;
%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != ""

var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<%
var HLooper1__numRows = -3;
var HLooper1__index = 0;
rs_App1B_numRows += HLooper1__numRows;
%>
<% if (rs_App1A.EOF) Response.Redirect("www.douglas-county.com/Employment/noaccess.asp"); %>
<%
Session("Seqno"


Session("App_ID"


Session("Password"


Session("Job_ID"


%>
<html>
<head>
<title>Douglas County, Kansas - Online Employment Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="keywords" CONTENT="Douglas County,Douglas County KS,Douglas County Kansas,Douglas,County,Kansas,Government,KS Government,Kansas Government,Stephen A. Douglas,Quantrill,Quantrill's Raid,Lawrence,Lecompton,Baldwin,Baldwin City,Eudora,Clinton,Jayhawks;KU,Kansas University,University of Kansas,University of KS,Baker University,Haskell,Haskell Indian Nations University,John Baldwin,Amos A. Lawrence,Samuel D. Lecompte,Kanzas Nation.">
<META NAME="description" CONTENT= "Official site for Douglas County, Kansas - Our mission is to provide for the safety and well being of the citizens of Douglas County through the professional and efficient delivery of essential public services in response to the needs of Douglas County citizens.">
<style type="text/css">
<!--
.roll { font-family:"Arial, Helvetica, sans-serif" size="1"; font-style:normal; font-weight:normal; letter-spacing:normal; text-decoration:underline; color:330066; }
A.roll:hover { size="1"; color:red; text-decoration:none;}
-->
INPUT, TEXTAREA {
font-family: "Arial, Helvetica, sans-serif";
padding: 1px;
font-size: 12px;
color: #000000;
background-color: #FFFFFF;
border: inset 2px #660000;
}
</style>
<script language="JavaScript">
<!--
<!-- Begin
if (window != top) top.location.href = location.href;
function NewWindow(mypage, myname, w, h, scroll)
{
var winl = (screen.width - w) / 1.5;
var wint = (screen.height - h) / 1.65;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
var isNN = (navigator.appName.indexOf("Netscape"

function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="660" border="0" align="left">
<tr>
<td valign="top" height="123" colspan="2">
<form name="form1" method="post" action="app_jobs3D2.asp">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC">
<tr>
<td valign="top" height="2">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="3" bgcolor="#660000"><font size="2" face="Arial, Helvetica, sans-serif" color="#FFFFFF"><b>Position(s) applying for:</b></font></td>
</tr>
<tr bgcolor="#FFFFCC" valign="top">
<td colspan="3" height="37">
<div align="left">
<%
var startrw=0;
var endrw=HLooper1__index;
var numberColumns=3;
var numrows=-1;
while((numrows-- !=0) && (!rs_App1B.EOF)) {
startrw=endrw + 1;
endrw = endrw + numberColumns;
%>
<%
while ((startrw <= endrw) && (!rs_App1B.EOF)) {
%>
<input <%=((rs_App1B.Fields.Item("Job_ID"



<font size="2" face="Arial, Helvetica, sans-serif"><%=(rs_App1B.Fields.Item("Job_Title"


</font>
<input type="hidden" name="hiddenField" value="<%Response.Write(Date())%>">
<input type="hidden" name="hiddenField2" value="<%=Session("App_ID"

<input type="hidden" name="MM_insert" value="true">
<%
startrw = startrw+1;
rs_App1B.MoveNext();
}
%>
<% }%>
</div>
</td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="3">
<p><font size="1" face="Arial, Helvetica, sans-serif" color="#FF0000"><b><img src="Images/bullet2.gif" width="8" height="8">To view details for each position, click on the 'View Details' links above.
</b></font>
</p>
</td>
</tr>
<tr>
<td bgcolor="#FFFFCC" valign="bottom" height="34" width="71%"><font size="2" face="Arial, Helvetica, sans-serif">If you have any questions about this form, please contact the Douglas County <a class=roll href="mailto: ">webmaster</a>.</font></td>
<td bgcolor="#FFFFCC" valign="bottom" height="34">
<div align="right">
<input type="hidden" name="hiddenField3" value="<%=Session("Password"

<a class=roll href="javascript:window.close()">
</a><a class=roll href="">
<input type="button" name="Button2" value="Cancel" onClick="window.close()">
</a>
<input type="submit" name="Submit" value="Add Job(s)">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<%
rs_App1A.Close();
%>
<%
rs_App1B.Close();
%>
INSERT PAGE (app_jobs3D2.asp:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/strConn.asp" -->
<%
if(String(Request.Form("checkbox"



if(String(Session("App_ID"



if(String(Request.Form("hiddenField"



%>
<%
var rs_App1A__MMColParam = "Seqno";
if(String(Request.QueryString("id"


rs_App1A__MMColParam = String(Request.QueryString("id"

}
%>
<%
var rs_App1A__varApp_ID = "%";
if(String(Session("App_ID"


rs_App1A__varApp_ID = String(Session("App_ID"

}
%>
<%
var rs_App1A__varPassword = "%";
if(String(Session("Password"


rs_App1A__varPassword = String(Session("Password"

}
%>
<%
var rs_App1A = Server.CreateObject("ADODB.Recordset"

rs_App1A.ActiveConnection = MM_strConn_STRING;
rs_App1A.Source = "SELECT * FROM dbo.Employment_App WHERE App_ID LIKE '"+ rs_App1A__varApp_ID.replace(/'/g, "''"



rs_App1A.CursorType = 0;
rs_App1A.CursorLocation = 2;
rs_App1A.LockType = 3;
rs_App1A.Open();
var rs_App1A_numRows = 0;
%>
<%
var rs_App1B = Server.CreateObject("ADODB.Recordset"

rs_App1B.ActiveConnection = MM_strConn_STRING;
rs_App1B.Source = "SELECT * FROM Jobs WHERE Job_ID NOT IN (SELECT Job_ID FROM Employ_Jobs) AND GetDate() BETWEEN Post_Startdate AND Post_Enddate ORDER BY Job_Title ASC";
rs_App1B.CursorType = 0;
rs_App1B.CursorLocation = 2;
rs_App1B.LockType = 3;
rs_App1B.Open();
var rs_App1B_numRows = 0;
%>
<%
var HLooper1__numRows = -3;
var HLooper1__index = 0;
rs_App1B_numRows += HLooper1__numRows;
%>
<% if (rs_App1A.EOF) Response.Redirect("www.douglas-county.com/Employment/noaccess.asp"); %>
<%
Session("Seqno"


Session("App_ID"


Session("Password"


%>
<%
// *** Insert Record: set variables
if (String(Request("MM_insert"


var startrw=0;
var endrw=HLooper1__index;
var numberColumns=3;
var numrows=-1;
while((numrows-- !=0) && (!rs_App1B.EOF)) {
startrw=endrw + 1;
endrw = endrw + numberColumns;
%>
<%
while ((startrw <= endrw) && (!rs_App1B.EOF)) {
%>
<%
// Script enabling multiple delete of records
// If there is no choice, the page "app_jobs3D2.asp" is loaded again
// and a message box alerts the user
var varJob_ID=String(Request.Form("checkbox"

if (varJob_ID !="undefined"

var parenthesisin="("; //var containing the string "("
var parenthesisout="


//Var "parenthesisin" and "parenthesisout" are added before and after the var "String(Request.Form("checkbox"

if (String(Request.Form("checkbox"



var Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_strConn_STRING;
// Create a command in "Data Bindings", type="INSERT", SQL="INSERT INTO dbo.Employ_Jobs (Job_ID, App_ID, Creation_Date) VALUES"
// varJob_ID is a var which value is "Request.Form("checkbox"

Command1.CommandText = "INSERT INTO dbo.Employ_Jobs (Job_ID, App_ID, Creation_Date) VALUES ('"+ Command1__varJob_ID.replace(/'/g, "''"



Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
Response.Redirect("app_jobsconf.asp"

}
%>
<%
startrw = startrw+1;
rs_App1B.MoveNext();
}
%>
<% }%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != ""

var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QueryString); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nextItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><font size="2" face="Arial, Helvetica, sans-serif">
This form is submitting. You should be redirected to App_Main.asp soon!</font>
</p>
<p><font size="2" face="Arial, Helvetica, sans-serif">Response.Redirect("www.douglas-county.com/Employment/redirect_main.asp"<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle></font></p>
</body>
</html>
<%
rs_App1A.Close();
%>
<%
rs_App1B.Close();}
%>