I have a form with 6 fields. 3 of fields have their own submit button (using button element). I have a select case conditional to capture what button was used. My "Case"'s do not catch the value. I use a request.form("v ariable") to catch the value of the button.
line 100 is where I catch the value, line 72 is the first of the 3 buttons. would be easier with javascript and onclick functions, but trying to learn ASP Classic. The purpose of this form is to build a query based on what they enter, so each case statement would assign the correct sql based on what they were using to search.
line 100 is where I catch the value, line 72 is the first of the 3 buttons. would be easier with javascript and onclick functions, but trying to learn ASP Classic. The purpose of this form is to build a query based on what they enter, so each case statement would assign the correct sql based on what they were using to search.
Code:
<form method="post" action="test-17.asp" >
<fieldset class="centerMe">
<span id="HotItems" >
Show Only Hot Items?
<input type="radio" name="hotItem" value="No" checked/><label for="No">No</label>
<input type="radio" name="hotItem" value="Yes" /><label for="Yes">Yes</label>
</span>
<span class="pipeLine">|</span>
<span>
<select required id="stateID" name="selectedState" style="display:inline;">
<option value="" selected ="selected">State Choice...</option>
<option value="AZ">Arizona</option>
<option value="CO">Colorado</option>
<option value="GA">Georgia</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="MN">Minnesota</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="SD">South Dakota</option>
<option value="UT">Utah</option>
<option value="WA">Washington</option>
<option value="WI">Wisconsin</option>
</select>
</span>
<%
dim hotItemYN
hotItemYN = request.form("hotItem")
dim objRs
Set objRs = Server.CreateObject("ADODB.Recordset")
dim sicInput
sicInput = request.Form("sicInput")
dim sicSQL
sicSQL= "Select distinct(SIC), SIC_Description from MatrixTable"
objRs.Open sicSQL, connectionStringToAccess
dim covRS
Set covRS = Server.CreateObject("ADODB.Recordset")
dim covSQL
coverageInput = request.Form("coverageInput")
covSQL = "select distinct(Coverages) from MatrixTable"
covRS.Open covSQL, connectionStringToAccess
''''''''create the drop down for Coverages '''''''
Response.Write "<select name='coverageInput' >"
response.write " <option value='' selected> Coverage Choice... </option>"
Do While Not covRS.EOF
'Response.Write "<TD>" & objRs("SIC") & "</TD>"
Response.Write "<option value='" & covRS("Coverages") & "'>'" & covRS("Coverages") & "'</option>"
covRS.MoveNext
Loop
Response.Write "</select>"
%>
<!-- <label for="mySearchBox">Search by SIC:</label> -->
<!-- <input class="" type="submit" /> -->
</fieldset>
<fieldset class="centerMe">
<!-- <label for="mySearchBox">Search with multiple Keywords:</label> -->
<input id="mySearchBox-keyword" name="textInput" class="formButtons" type="text">
<button class="input" type="submit" name="mySubmit" value="keywordSubmit">Search by Keyword</button>
</fieldset>
<fieldset class="centerMe">
<!-- <label for="mySearchBox">Search with multiple Keywords:</label> -->
<input id="mySearchBox-sicDescription" name="textInput" class="formButtons" type="text">
<button class="input" type="submit" name="mySubmit" value="SicSubmit">Search by SIC Description</button>
</fieldset>
<fieldset class="centerMe">
<!-- <label for="mySearchBox">Search with multiple Keywords:</label> -->
<input id="mySearchBox-SIC" name="textInput" class="formButtons" type="text">
<button class="input" type="submit" name="mySubmit" value="sicDescrSubmit">Search by SIC</button>
</fieldset>
</form>
<%
'Which submit button was used? asign the proper SQL to the button'
dim mySubmit
Dim sicDescrSubmit, myQuery, keywordSubmit, SicSubmit
mySubmit = request.form("mySubmit")
if mySubmit <> "" then
Select Case mySubmit
Case sicDescrSubmit
myQuery="sicDescrSubmit"
Case SicSubmit
myQuery="SicSubmit"
Case keywordSubmit
myQuery="keywordSubmit"
response.write("keywordSubmit")
Case Else
response.write("Please Submit one of the buttons")
End Select
else myQuery = ""
End if
response.write myQuery
Comment