Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp: dynamically create 2nd part of form from access db

Status
Not open for further replies.

selaine

Programmer
Oct 11, 2001
85
US
The code for my first page is pulled from a table called tblCategory and it works fine. My problem is I'm not sure how to approach page 2. I need to hold on to all of the information from page 1, to use for page 2.

<table width=&quot;500&quot;>
<form action=&quot;info2.asp&quot; method=&quot;get&quot;>
<tr>
<td width=&quot;500&quot; align=&quot;center&quot;>
<% 'Request the name of Category and the primary key from the tblCategory table.
SQLCK=&quot;SELECT Category, ckbox_name, CategoryID FROM tblCategory&quot;
set connck = server.createobject(&quot;ADODB.Connection&quot;)
connck.open &quot;Checkboxes&quot;
set tblCategory=connck.execute(SQLCK)
%>

<% 'Loop through the recordset to make each entry in the list. %>
<% do while not tblCategory.eof %>
<tr>
<td><font face=&quot;Arial,Helvetica&quot; size=-1><%= tblCategory.Fields(&quot;Category&quot;).Value %></font></td>
<td><input type=&quot;checkbox&quot; name=&quot;<%=tblCategory.Fields(&quot;ckbox_name&quot;).Value %>&quot; value=&quot;<%=tblCategory.Fields(&quot;CategoryID&quot;).Value %>&quot;></td>
</tr>

<%tblCategory.movenext
loop%>

<% connck.close %>
</table>

<p><input type=&quot;Submit&quot; value=&quot;Proceed with Registration&quot; align=&quot;LEFT&quot;>
</form>


***********************************************************
The above code results in what you see below:
(first two columns displaying and last two columns of values in source)

-----------------------------------------------------------
Goods and/or Services:
Please select from the General Categories below, any that apply:

Automotive [] name=ckAuto value=1000
Building Materials [] name=ckBldMat value=1200
Chemicals [] name=ckChem value=1400
Computing Networking [] name=ckComput value=1600
Construction Contractors [] name=ckConstr value=1800
Floor Covering [] name=ckFloor value=2000
Forms PrePrinted [] name=ckForms value=2200
Furniture Office [] name=ckFurnOfc value=2400
Heat-Ventilation-A/C [] name=ckHVAC value=2600

-----------------------------------------------------------
^=Category ^=ckbox_name ^=CategoryID

I need to determine which of the checkboxes were selected and their value, in order to
dynamically create a new set of checkboxes per selection. Lets say the user selects
Building Materials and Construction Contractors (values of 1200 and 1800 selected). I
need to take those values (number of values to use based on how many checkboxes the
user selects, so will vary) and use them in an SQL that will dynamically create the new
set of checkboxes from another table (tblSubCategory) in the same database (using
Access 2000). If the user selected Building Materials, the value of 1200 may be found
one or more times in the tblSubCategory and for each time its found needs a checkbox.
If the user also selects Construction Contractors, the value 1800 would be used to
search the table &quot;tblSubCategory&quot; and create its set of checkboxes, values and names,
etc., etc., I'm sure I'll need one or more loops to accomplish this, but am unsure
about how to do it, since I'm not very good with loops (they're very confusing)

***********************************************************
If the user selected Building Materials and Construction Contractors on page 1, the
resulting page would look something like this:

-----------------------------------------------------------
You have selected &quot;Building Materials&quot; and &quot;Construction Contractors&quot; from the General
Category list - please provide us with more information by selecting from their more
detailed selection below:

Building Materials:
Doors [] name=ckDoors value=1201
Elec./Light Equip [] name=ckElect value=1202
Hardware [] name=ckHardw value=1203
Lumber - Plywood [] name=ckLumbr value=1204
Plumbing [] name=ckPlumb value=1205
Windows [] name=ckWindw value=1206

Construction Contractors:
Architectural [] name=ckArch value=1801
Asbestos Removal [] name=chAsbes value=1802
Asphalt Paving [] name=ckAsphl value=1803
Carpentry [] name=ckCarpn value=1804
Concrete [] name=ckCncrt value=1805
Demolition [] name=ckDemo value=1806
Electrical [] name=ckElec value=1807
Engineering - Civil [] name=ckEngCv value=1808
Engineering - Elec. [] name=ckEnElc value=1809
Engineering - Mech. [] name=ckEnMch value=1810
Engineering - Struc. [] name=ckEnStr value=1811
Excavating [] name=ckExcav value=1812
Plumbing [] name=ckCCPlm value=1813

-----------------------------------------------------------
^=SubCat ^=SubCk_Name ^=SubID

I will problably want to use an include for building the page and I think my code
will have to be along the line of this:

varnum = number of checkboxes selected from page 1

Loop to count number of checkboxes selected from previous page
End Loop

varCkValue = value from checkbox

Loop varnum times
Get value of checkbox selected
Do while tblSubCategory.CategoryID = varckvalue
SELECT SubID, CategoryID, SubCat, SubCk_Name FROM tblSubCategory
<tr>
<td><font face=&quot;Arial,Helvetica&quot; size=-1><%= tblSubCategory.Fields(&quot;SubCat&quot;).Value %></font></td>
<td><input type=&quot;checkbox&quot; name=&quot;<%=tblSubCategory.Fields(&quot;SubCk_Name&quot;).Value %>&quot; value=&quot;<%=tblSubCategory.Fields(&quot;SubID&quot;).Value %>&quot;></td>
</tr>

tblSubCategory.movenext
End Loop
End Loop

I think I might have the right idea, but have no clue how to approach it.
Any help would really be appreciated!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top