CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Multiple Form Selection
Allowing multiple choices of data elements enables people to customize views of your data and adds value to your applications. The following example utilizes our db on the career statistics of Hammeriní Hank Greenberg. The year and team he played with are already part of the sql request to the db. User inputted choice(s) are added to the basic sql statement to draw them from the db. Since the input from the dropdown menu comes through comma delimited it is simply written into the statement without modification. Two simple for next loops determine which elements are part of the record set and displays them accordingly.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<html>
<title>CodeAve.com(Multiple Form Selection)</title>
<body bgcolor="#FFFFFF">
<%' Check to see if there is any input
' if not display the form for input
u_input=request.form("u_input")
if u_input = "" then %>


<form action="<%= request.servervariables("script_name")%>" method="post">
Select One, Many, or All elements to display<br>
<select size="5" name="u_input" multiple>
<option value="AVG">AVG</option>
<option value="AB">AB</option>
<option value="R">R</option>
<option value="H">H</option>
<option value="Double">Double</option>
<option value="Triple">Triple</option>
<option value="HR">HR</option>
<option value="RBI">RBI</option>
<option value="BB">BB</option>
<option value="SO">SO</option>
<option value="SB">SB</option>
</select>
<input type="submit" value="Submit">
</form>

<%' When there is input display the data
else
' Name of the Access db
accessdb="greenberg" 

' Connection to the db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server record set object
set rs = server.createobject("ADODB.Recordset")

' Create an sql statement that will select the elements Year, Team
' and any user inputtted selections. A single selection will simply
' add that element to the list. Multiple selections will be passed
' already comma delimited. The sql statement is written to the browser
' to demonstrate this. 
sql = "select Year, Team, "& u_input &" from hammerin_hank " 

' Execute the sql 
rs.Open sql, cn
%>


<table border=3 align=center>
<caption><%= sql%><tr>
<% ' Write out all the elements requested in the 
' sql statement as table headers
for each element in rs.fields%>

<th><%= element.name %></th>
<% next
' End table headers %>

</tr>
<tr>
<% ' Write out all the values in the record 
do while not rs.eof 
for each element in rs.fields %>

<td align=right><%= rs(element.name) %></td>
<% 
next
' end of record %>

</tr>
<% ' Move to the next record
rs.movenext
' Loop to the beginning
loop%>

</table>
<% end if 'End check for user input %>
</body>
</html>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3