473,671 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

case select capture value from which button was clicked

2 New Member
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.
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
2 6785
jhardman
3,406 Recognized Expert Specialist
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
jim54729
2 New Member
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
16027
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 statement like as follows in the PageLoad: private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { //do something here } else {
4
1901
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 me to check in Page_Load which of the buttons have been clicked? Thanks, Shawn
1
1240
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 function. Can anyone supply me with the specific case statement code to determine which button has been clicked? The posts that I found only have code samples in C# tia,
3
10479
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 event: Dim prodkey As String = CType(FindControl("txtProductkey"), TextBox).Text.ToString() Response.Redirect("store_shoppingcart.aspx?pkey=" & prodkey)
2
1530
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
3405
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 selection from select list. Initially I tried to disble the selection control. And when user will click the radio then only it was enabled. but I faced problem that value is not passed to the next form of the select list. so I enable the select list now...
1
5893
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
19102
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(""); response.contentType="text/html"; response .writefile(""); it displayed in different format and images not shown blank spaces shown as ?????????? and image as X.
1
2087
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 System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'MDRDataSet5.scratchpad2' table. You can move, or remove it, as needed. ...
0
8401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6236
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.