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

LVL 1
wellsuitedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wellsuitedAuthor Commented:
sorry I forgot to remove that. I was trying a different method.
0
wellsuitedAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.