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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down Box Loops and Placement on Grid

Status
Not open for further replies.

jacob94

Technical User
Dec 5, 2005
161
US
Hello,
Thanks to emozley and sheco I was able to develop a dynamic drop down list that reads from my db.

<%
'Open the database.
call OpenDB()

sql = "select * from view"
set rs = DbConn.Execute(sql)
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<FORM name=brackets>

<%

Do While Not rs.EOF

%>

<select name="GameID<% = rs("GameID") %>">

<option value="<% = rs("VisitorID") %>" <% If rs("VisitorID")=rs("Selection") Then Response.Write("SELECTED") %>>

<% = rs("VisitorID") %>

</option>


<option value="<% = rs("HomeID") %>" <% If rs("HomeID")=rs("Selection") Then Response.Write("SELECTED") %>>

<% = rs("HomeID") %>

</option>

</select>

<%

rs.MoveNext
Loop

rs.Close
Set rs=Nothing
Set dbConn=Nothing

%>


<br>
<input name="SubmitButton" type="submit" id="SubmitButton" value="Submit">

</FORM>

</body>
</html>

What I need to do with the drop down boxes is place them throughout my ASP page in a table/grid like format.

How can I do this with the loop involved.

I need to have 8 boxes in different locations on my page.
 
The way I solve this kind of problem is to actually make a simple static HTML page that has basic layout that I require...

Then I print it out on paper...

Then I write and test the ASP logic that will create the same HTML.

Only after i have this "shell" do I go add all the pretty things and error checking and such. I find using this technique it is easier for me to concentrate on the core problem.


Tip: You can count the rows and get the modulus of the counter and the number of boxes per row.
[tt]
1 Mod 8 = 1 <--- row A begins
2 Mod 8 = 2
3 Mod 8 = 3
4 Mod 8 = 4
5 Mod 8 = 5
6 Mod 8 = 6
7 Mod 8 = 7
8 Mod 8 = 0 <--- row A ends
9 Mod 8 = 1 <--- row B begins
10 Mod 8 = 2
11 Mod 8 = 3
12 Mod 8 = 4
13 Mod 8 = 5
14 Mod 8 = 6
15 Mod 8 = 7
16 Mod 8 = 0 <--- row B ends
17 Mod 8 = 1 <--- row C begins
18 Mod 8 = 2
19 Mod 8 = 3
20 Mod 8 = 4
...
[/tt]

This is a way you could programmatically use the row count to determine when a row begins and ends.

 
Sheco's method looks good as it is not dependent on the number of records in the database.

Jacob94 - are you familiar with the HTML structure of tables? If not here are the basics:

<table> - Starts the table
<tr> - Starts a new row
<td> - Starts a new cell
</td> - Closes the cell
</tr> - Ends the row
</table> - Ends the table

How do you want the drop down menus arranged? Do you want them in a single column, two columns with four rows or 4 columns and two rows?
 
I do not understand that method at all. Can I have one example that would relate to mine.

Here is my actual form and table. I will need to place the DropDowns where you see DD. Paste my code into an html file and see for yourself.

<FORM name=brackets>
<TABLE border=1>
<TBODY>
<TR>
<TD class=s3>&nbsp;</TD>
<TD>
<DIV class=s3 align=center>1</DIV>
</TD>
<TD>
<DIV class=s3 align=center>2</DIV>
</TD>
<TD>
<DIV class=s3 align=center>3</DIV>
</TD>
<TD>
<DIV class=s3 align=center>4</DIV>
</TD>
<TD>
<DIV class=s3 align=center>5</DIV>
</TD>
<TD>
<DIV class=s3 align=center>6</DIV>
</TD></TR>
<TR>
<TD class=s2 noWrap>1.&nbsp;&nbsp; <BR>
16. </TD>
<TD class=s2 vAlign=center noWrap>


DD</TD>
<TD class=s2 vAlign=center noWrap align=middle rowSpan=2><br>
<BR></TD>
<TD class=s2 vAlign=center noWrap align=middle rowSpan=4><BR></TD>
<TD class=s2 vAlign=center noWrap align=middle rowSpan=8><BR></TD>
<TD class=s2 vAlign=center noWrap align=middle rowSpan=10><BR></TD>
<TD class=s2 vAlign=center noWrap align=middle rowSpan=12><BR></TD>
</TR>
<TR>
<TD class=s2 noWrap>8.&nbsp;&nbsp; <BR>
9.&nbsp;&nbsp; </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>
</TR>
<TR>
<TD class=s2 noWrap>5.&nbsp;&nbsp; <BR>
12. </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>

<TD class=s2 vAlign=center noWrap align=middle rowSpan=2><BR></TD> </TR>
<TR>
<TD class=s2 noWrap>4.&nbsp;&nbsp; <BR>
13. </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>
</TR>
<TR>
<TD class=s2 noWrap>3.&nbsp;&nbsp; <BR>
14. </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>

<TD class=s2 vAlign=center noWrap align=middle rowSpan=2><BR></TD>
<TD class=s2 vAlign=center noWrap align=middle rowSpan=4><BR></TD>
<TR>
<TD class=s2 noWrap>6.&nbsp;&nbsp; <BR>
11. </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>
</TR>
<TR>
<TD class=s2 noWrap>7.&nbsp;&nbsp; <BR>
10. </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>

<TD class=s2 vAlign=center noWrap align=middle rowSpan=2><BR> </TD> </TR>
<TR>
<TD class=s2 noWrap>2.&nbsp;&nbsp; <BR>
15. </TD>
<TD class=s2 vAlign=center noWrap>DD</TD>
</TR>
<TR></TR>
<TR>

</TR>
<TR></TR>
</TBODY></TABLE>

<br>
<input name="SubmitButton" type="submit" id="SubmitButton" value="Submit">
<BR>
</FORM>
 
This is not going to be totally straightforward but it is possible. Just a couple of questions:

1. Are the numbers down the left hand side from the database? If so which table are they stored in and what are the column names? This app should be dynamic - once the page is written it should never need to be edited again.

2. Are you absolutely certain this is the layout you want to go for? Nothing wrong with it as such but even a small change could involve a lot of fiddling with thr code once it's been done once!

cheers
 
Thanks guys for pointing me to the right area for this. I was out sick for while so that is why i did not post back. in any event you were a tremndous help to getting to the soultion so thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top