Join us on Facebook!
28
Feb

Multiple Form Selection

by admin 1849 views 0 Comments and 0 Rections

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.

  
CodeAve.com(Multiple Form Selection)

<%' 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 %>

" method="post">
Select One, Many, or All elements to display





<%' 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
%>



<% ' Write out all the elements requested in the
' sql statement as table headers
for each element in rs.fields%>

<% next
' End table headers %>


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

<%
next
' end of record %>

<% ' Move to the next record
rs.movenext
' Loop to the beginning
loop%>
<%= sql%>
<%= element.name %>
<%= rs(element.name) %>

<% end if 'End check for user input %>

More Posts in "Tutorials"

Comments

blog comments powered by Disqus

Feed Subscription

Get daily inboxed with latest news, reviews and tutorials. Signup now it's free :)



Planetmaks on Twitter

Follow PlanetMaks on Facebook

Recent Comments

Powered by Disqus

Tags

32Bit 64Bit 7 Admin Tool Admin Tools Admin-Tool Admin-Tools AdminTool Adobe Adware All-in-One Anti-Spyware Anti-Virus Apple Backup Tools Browser Browsers Changing Default Directory Codec Data Recovery Download Manager Downloads Drive Utilities Driver Drivers Firefox Flash Freeware Google Graphics Internet Tool Internet-Tool Messaging Microsoft Microsoft Tool Micsellonous Monitoring Multimedia Networking News NVidia Office Tool Office-Tool PC Suite Press Release Registry Samsung Security Shareware Software Softwares Tutorials Vista Windows Windows 7 Windows 8