473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

case select capture value from which button was clicked

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("variable") 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.
Expand|Select|Wrap|Line Numbers
  1.  <form method="post" action="test-17.asp" >         
  2.              <fieldset class="centerMe">
  3.                  <span id="HotItems" >
  4.                      Show Only Hot Items?
  5.                      <input type="radio" name="hotItem" value="No"  checked/><label for="No">No</label>
  6.                      <input type="radio" name="hotItem" value="Yes" /><label for="Yes">Yes</label>                     
  7.                  </span>
  8.                  <span class="pipeLine">|</span>
  9.                  <span>
  10.                     <select required id="stateID"  name="selectedState"  style="display:inline;">
  11.                       <option value="" selected ="selected">State Choice...</option>                     
  12.                       <option value="AZ">Arizona</option>                     
  13.                       <option value="CO">Colorado</option>                    
  14.                       <option value="GA">Georgia</option>                    
  15.                       <option value="ID">Idaho</option>
  16.                       <option value="IL">Illinois</option>
  17.                       <option value="IN">Indiana</option>
  18.                       <option value="IA">Iowa</option>
  19.                       <option value="KS">Kansas</option>                      
  20.                       <option value="MN">Minnesota</option>                    
  21.                       <option value="MO">Missouri</option>
  22.                       <option value="MT">Montana</option>
  23.                       <option value="NE">Nebraska</option>
  24.                       <option value="NV">Nevada</option>                    
  25.                       <option value="ND">North Dakota</option>
  26.                       <option value="OH">Ohio</option>                    
  27.                       <option value="SD">South Dakota</option>                     
  28.                       <option value="UT">Utah</option>                     
  29.                       <option value="WA">Washington</option>                     
  30.                       <option value="WI">Wisconsin</option>                      
  31.                     </select>
  32.                 </span>
  33. <%
  34.  
  35.                     dim hotItemYN
  36.                      hotItemYN = request.form("hotItem")
  37.                     dim objRs
  38.                     Set objRs = Server.CreateObject("ADODB.Recordset")
  39.                     dim sicInput
  40.                     sicInput = request.Form("sicInput")        
  41.                     dim sicSQL
  42.                     sicSQL= "Select distinct(SIC), SIC_Description from MatrixTable"
  43.  
  44.                     objRs.Open sicSQL, connectionStringToAccess
  45.  
  46.                     dim covRS        
  47.                     Set covRS = Server.CreateObject("ADODB.Recordset")
  48.                     dim covSQL
  49.                     coverageInput = request.Form("coverageInput")
  50.                     covSQL = "select distinct(Coverages) from MatrixTable"
  51.                     covRS.Open covSQL, connectionStringToAccess
  52.  
  53.  
  54.                     ''''''''create the drop down for Coverages '''''''
  55.                     Response.Write "<select name='coverageInput' >"
  56.                     response.write " <option value='' selected> Coverage Choice... </option>"
  57.  
  58.                         Do While Not covRS.EOF 
  59.                         'Response.Write "<TD>" & objRs("SIC") & "</TD>"
  60.                             Response.Write "<option value='" & covRS("Coverages") & "'>'" & covRS("Coverages") & "'</option>"
  61.                         covRS.MoveNext
  62.                         Loop
  63.                     Response.Write "</select>"
  64.  
  65. %>
  66.                 <!-- <label for="mySearchBox">Search by SIC:</label> -->
  67.  
  68.                 <!-- <input class="" type="submit"  /> -->
  69.  
  70.  
  71.             </fieldset>
  72.             <fieldset class="centerMe">
  73.                    <!-- <label for="mySearchBox">Search with multiple Keywords:</label> -->
  74.                    <input id="mySearchBox-keyword" name="textInput" class="formButtons" type="text">
  75.                    <button class="input" type="submit" name="mySubmit" value="keywordSubmit">Search by Keyword</button>
  76.                </fieldset>
  77.             <fieldset class="centerMe">
  78.                    <!-- <label for="mySearchBox">Search with multiple Keywords:</label> -->
  79.                    <input id="mySearchBox-sicDescription" name="textInput" class="formButtons" type="text">
  80.                    <button class="input" type="submit" name="mySubmit" value="SicSubmit">Search by SIC Description</button>
  81.                </fieldset>
  82.             <fieldset class="centerMe">
  83.                    <!-- <label for="mySearchBox">Search with multiple Keywords:</label> -->
  84.                    <input id="mySearchBox-SIC" name="textInput" class="formButtons" type="text">
  85.                    <button class="input" type="submit" name="mySubmit" value="sicDescrSubmit">Search by SIC</button>
  86.                </fieldset>
  87.  
  88.         </form> 
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.                 <% 
  97.                 'Which submit button was used? asign the proper SQL to the button'
  98.                 dim mySubmit 
  99.                 Dim sicDescrSubmit, myQuery, keywordSubmit, SicSubmit
  100.                 mySubmit = request.form("mySubmit")
  101.                 if mySubmit <> "" then
  102.                     Select Case mySubmit
  103.                         Case sicDescrSubmit
  104.                             myQuery="sicDescrSubmit"
  105.                         Case SicSubmit 
  106.                             myQuery="SicSubmit"
  107.                         Case keywordSubmit
  108.                             myQuery="keywordSubmit"
  109.                             response.write("keywordSubmit")
  110.                         Case Else
  111.                             response.write("Please Submit one of the buttons")
  112.                     End Select
  113.                 else myQuery = ""
  114.                 End if
  115.                 response.write myQuery
  116.  
Sep 11 '17 #1

✓ answered by jhardman

is this going to the case else every time?

syntax should be:

Expand|Select|Wrap|Line Numbers
  1.    Case "sicDescrSubmit"
  2.                             myQuery="sicDescrSubmit"
  3.                         Case "SicSubmit"
  4.                             myQuery="SicSubmit"
value should be in quotes. but I'm not sure that is the only issue.

2 6675
jhardman
3,406 Expert 2GB
is this going to the case else every time?

syntax should be:

Expand|Select|Wrap|Line Numbers
  1.    Case "sicDescrSubmit"
  2.                             myQuery="sicDescrSubmit"
  3.                         Case "SicSubmit"
  4.                             myQuery="SicSubmit"
value should be in quotes. but I'm not sure that is the only issue.
Nov 28 '17 #2
Thank you Jhardman. I did give up and put them all in one form instead, but now I see what I did wrong. Thanks
Nov 30 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Amadelle | last post by:
Hi all and thanks in advance, I am stuck! I can't figure out how to identify which button was clicked on my ASP.NET page in the PostBack event? So what I am trying to do is to is to have an if...
4
by: Shawn | last post by:
Hi. I have a ToolBar with a couple of ToolBarButtons. On postback after clicking on of the buttons Page_Load is called first then the ToolBarButton's click event is called. Is there anyway for...
1
by: Mac via DotNetMonster.com | last post by:
Hi all, I have searched some old posts and it appears that to run some code for a particular button that has been clicked on a toolbar, I need to have a case statement in the toolbar click event...
3
by: AlecL | last post by:
Hi All, I am trying to capture the value of a textbox as a result of a button click event in a repeater, but it can't find the textbox. Here is what I am trying to do in the code for the click...
2
by: John | last post by:
Hi, I would like to create an eventhandles that handles several different buttons. How can I detect which button was clicked on ? I know it something with the sender ... something like
10
by: mukeshrasm | last post by:
Hi I have a html in which there is two selection box and two radio button. Radio buttion is of array type. What I want if user will click the radio button then only he/she be able to make...
1
by: tiijnar | last post by:
Hi, I am using a JSP in my application. In JSP page I created tables and buttons inside a loop. <% i=0; while(i<4) { %> <table align="left" width="100%"> <tr>
23
by: shashi shekhar singh | last post by:
Dear sir, I have a word document file contains text and images, now i have saved it as a web page and wants to display it on browser , using , string str=directory.getfiles("");...
1
by: dougancil | last post by:
I have a form that has a datatable on it with the following code: Imports System.Data.SqlClient Imports System.Data Public Class AddHoliday Private Sub AddHoliday_Load(ByVal sender As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.