• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Multiple Insert with checkboxes

My form is in a loop, but if a checkbox is not checked that is in sequence, meaning you miss a row from being checked I get the error "Type Mismatch"
<%
if request("Submit") <> "" Then
codeidarray=split(request("CodeID") & intRecID,",")
pricearray=split(request("price") & intRecID,",")
customerarray=split(request("customerID"),",")
for i=0 to ubound(codeidarray)
rs2.addnew
rs2("CodeID")=trim(codeidarray(i))
rs2("Price")=trim(pricearray(i))
rs2("CustomerID")=trim(customerarray(i))
rs2.update
next
response.redirect "estimates.asp"
end if
%>
 
 
<input name="" type="checkbox" id="CodeID" value="<%=(rs.Fields.Item("CodeID").Value)%>" />
               <input name="price" type="text" id="price" size="5" />
                <input name="CustomerID" type="hidden" id="CustomerID" value="<%=(rsCustomer.Fields.Item("CustomerID").Value)%>" />

Open in new window

0
wellsuited
Asked:
wellsuited
  • 5
  • 3
  • 2
1 Solution
 
Ryan ChongCommented:
try change:

if request("Submit") <> "" Then

to:

if request("Submit") <> "" and request("CodeID") <> "" and request("price") <> "" and request("customerID") <> "" Then
0
 
wellsuitedAuthor Commented:
no, I get the same thing.
0
 
quincydudeCommented:
You may try to add another hidden input as a hidden list of all Code ids and loop through it in the program in the idea below. I didn't test the code though. Hope this helps.
<%
if request("Submit") <> "" Then
codeidarray=split(request("CodeID") & intRecID,",")
hiddenCodeID=split(request("hCodeID") & intRecID,",")
pricearray=split(request("price") & intRecID,",")
customerarray=split(request("customerID"),",")
 
for j=0 to ubound(hiddenCodeID)
	for i=0 to ubound(codeidarray)
		if trim(hiddenCodeID(j) = trim(codeidarray(i)) Then
			rs2.addnew
			rs2("CodeID")=trim(codeidarray(i))
			rs2("Price")=trim(pricearray(i))
			rs2("CustomerID")=trim(customerarray(i))
			rs2.update
		end if
	next
next
 
response.redirect "estimates.asp"
end if
 
%>
 
 
<input name="" type="checkbox" id="CodeID" value="<%=(rs.Fields.Item("CodeID").Value)%>" />
<input name="hCodeID" type="hidden" id="hCodeID" value="<%=(rs.Fields.Item("CodeID").Value)%>" />
               <input name="price" type="text" id="price" size="5" />
                <input name="CustomerID" type="hidden" id="CustomerID" value="<%=(rsCustomer.Fields.Item("CustomerID").Value)%>" />

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wellsuitedAuthor Commented:
No that didnt work either.
0
 
Ryan ChongCommented:
>>Type Mismatch

Check if the value captured is matched with the data type of the field in your table?
0
 
Ryan ChongCommented:
why there is a need to add " & intRecID" in your script before split it?
0
 
wellsuitedAuthor Commented:
It is. if i check all of the boxes it works fine, and if I check consecutive lines it works.
0
 
quincydudeCommented:
oops, forgot to change the counter values
<%
if request("Submit") <> "" Then
codeidarray=split(request("CodeID") & intRecID,",")
hiddenCodeID=split(request("hCodeID") & intRecID,",")
pricearray=split(request("price") & intRecID,",")
customerarray=split(request("customerID"),",")
 
for j=0 to ubound(hiddenCodeID)
	for i=0 to ubound(codeidarray)
		if trim(hiddenCodeID(j) = trim(codeidarray(i)) Then
			rs2.addnew
			rs2("CodeID")=trim(codeidarray(i))
			rs2("Price")=trim(pricearray(j))
			rs2("CustomerID")=trim(customerarray(j))
			rs2.update
		end if
	next
next
 
response.redirect "estimates.asp"
end if
 
%>
 
 
<input name="" type="checkbox" id="CodeID" value="<%=(rs.Fields.Item("CodeID").Value)%>" />
<input name="hCodeID" type="hidden" id="hCodeID" value="<%=(rs.Fields.Item("CodeID").Value)%>" />
               <input name="price" type="text" id="price" size="5" />
                <input name="CustomerID" type="hidden" id="CustomerID" value="<%=(rsCustomer.Fields.Item("CustomerID").Value)%>" />

Open in new window

0
 
wellsuitedAuthor Commented:
sorry I forgot to remove that. I was trying a different method.
0
 
wellsuitedAuthor Commented:
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now