Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2015, 09:57 PM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple Inserts from Multiple checkboxes

I have a page that first looks up a list of courses, as the results list is being built in HTML using classic ASP, I add a checkbox at the end of each <TR>. The checkbox name is built dynamically, i.e., each checkbox name is built as "checkbox1", checkbox2, etc. Each checkbox is assigned a value from two fields from each row of the objRS (resultset) so that the value is formed in the form of a value list of an sql insert clause.

The code that builds this RS is:

Code:
objRSschedule.Open strSQL, strConn, 3, 3

Response.Write "<table class=""auto-style5"" border=""0"" cellpadding=""1"" cellspacing=""0"" style=""vertical-align: bottom"">" &_
"<tr class=""auto-style7""><td colspan=""4""><b><u>List of Available Classes</u></b></TD></tr><P></P>" & _
"<P></P><tr class=""auto-style6""><td>Class Name |</TD><td> Class Date |</TD><td> Class Time |</TD><td> Enroll Me</TD></tr>"


Do Until objRSschedule.EOF = True
intChkBxVal = intChkBxVal + 1
Response.Write "<TR class=""auto-style5"">" & _
				"<td>" & objRSschedule ("ClassName") & "</TD>" & _
				"<td>" & objRSschedule ("ClassDate") & "</TD>" & _
				"<td>" & objRSschedule ("ClassTime") & "</TD>" & _
				"<td><input name=""Checkbox" & intChkBxVal & """type=""checkbox"" Value=""('" & strContactID &  "','" & objRSschedule("ClassID")& "')""></TD>" & _				
			
				"</TD></TR>"
The resulting HTML list looks like this:

List of Available Classes

Class Name |Class Date |Class Time |Enroll Me

Spin 1/12/2015 7:00 PM [checkbox]

Spin 1/17/2015 6:00 AM [checkbox]

Spin 1/26/2015 5:00 AM [checkbox]

TRX 1/27/2015 7:00 AM [checkbox]

If you were to inspect the checkbox elements presented on the web page, the resulting HTML code looks like this:

<input name="Checkbox1" type="checkbox" value="('1','160')">

AND

<input name="Checkbox2" type="checkbox" value="('1','159')"> ,
etc., for each class returned.

I would like the user to be able to check multiple checkboxes AND based on the boxes checked, have the value in the Value clause be the value of the insert clause to be entered into another table, classSignup. Ex.

INSERT INTO ClassSignup
VALUES ('1','159'); <----- this value string is what needs to be inserted in the ClassSignup table

Is there any way to do this without forcing the user to do a separate insert operation for for each box checked?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Inserts ~Bean~ SQL Language 1 January 20th, 2006 03:00 PM
Trigger support for multiple Inserts kim3er SQL Server 2000 1 November 6th, 2004 02:51 AM
Multiple Checkboxes With same name how to make t kcs_chandra ASP.NET 1.0 and 1.1 Basics 1 October 29th, 2004 09:03 AM
Multiple Checkboxes Error mgreenwood BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 May 27th, 2004 02:43 PM
multiple dynamic checkboxes mlog Classic ASP Basics 0 February 14th, 2004 04:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.