Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detect which button has been pressed? 1

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
my current way of detecting whuch button on a form has been pressed using asp is setting the value of the button like e.g.:<br><br>------------------------------------<br>&lt;INPUT name=&quot;Customers&quot; TYPE=&quot;submit&quot;&nbsp;&nbsp;VALUE=&quot;Backed Up&quot; onclick=&quot;javascript:gotonectpage(this);&quot;&gt;<br>------------------------------------<br><br>Then is ASP I detect<br>the button pressed by e.g.:<br><br>------------------------------------<br>strAlt = Request.Form(&quot;Customers&quot;)<br><br>Select Case strAlt<br><br> Case &quot;Backed Up&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;......<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End select<br>------------------------------------<br><br>I was wondering is there a better way to detect which button has been pressed in ASP. This is because I have to give my buttons names I don't want on screen like &quot;Back Up&quot; instead it would be better if I could have two buttons with the same name onscreen that do to different things.<br><br>grateful for any help given, thankz.<br>
 
I'm not exactly sure what you mean. Could you explain the last sentence of your post better.&nbsp;&nbsp;It sounds like you want both buttons to say 'Back Up'. Is that right? <p>ray<br><a href=mailto:rheindl@bju.edu>rheindl@bju.edu</a><br><a href= > </a><br>
 
yeah thats sort of right, I want two or more buttons to be labelled &quot;Search&quot; and for the asp to figure out what button has been pressed. Right now, I'm using the value of the button to differentiate between different buttons but this means I have to give different names to my buttons such as &quot;Search Customer ID&quot; , &quot;Search ID&quot; (which shows on the screen).<br><br>hope that clears things up, ray.<br><br>
 
Taval,<br>this is where you start going in the wrong direction:<br>I have to give <font color=red>different names to my buttons</font> such as &quot;Search Customer ID&quot; , &quot;Search ID&quot; (which shows on the screen).<br>You should use same name for all of your submit buttons and different values for each of them e.g.:<br>&quot;Search Customer ID&quot; , &quot;Search ID&quot;<br>And in in your next page you would use<br><br>Select Case request.form(&quot;buttonnamegoeshere&quot;)<br>case &quot;Search ID&quot;<br>-------------<br>case &quot;somethingelse&quot;<br>----------------<br>end select<br><br>In VBScript I've already posted a way to solve your problem,<br>using just one submit button and few radio buttons.<br>You could go there and try to find one of your questions. <br><br>
 
yeah, I give my buttons the same name but the value determines what is written on the button and this is how asp determines which button has been pressed, I hope I'm being clear.<br><br>with this code e.g:<br><br>--------------<br>&lt;INPUT name=&quot;Customers&quot; TYPE=&quot;submit&quot;&nbsp;&nbsp;VALUE=&quot;Backed Up&quot; onclick=&quot;javascript:gotonectpage(this);&quot;&gt;<br>&lt;INPUT name=&quot;Customers&quot; TYPE=&quot;submit&quot;&nbsp;&nbsp;VALUE=&quot;Backed Up Now&quot; onclick=&quot;javascript:gotonectpage(this);&quot;&gt;<br>---------------<br><br>As you can see I have given them the same name, so I can check these class of buttons but the names are different &quot;Backed Up&quot; and =&quot;Backed Up Now&quot;. The VALUE is what is actually written on the button. My problem is what if I wanted both buttons to have &quot;Search&quot; written on them, but at the same time for asp to determine which button has been pressed.<br><br>hope this helps.<br>thanx.
 
If you want the buttons to say the same thing, then give them a different name.&nbsp;&nbsp;Then in your asp, do something like<br>If Request(&quot;button1&quot;) = &quot;Backed Up&quot; Then<br>...<br>ElseIf Request(&quot;button2&quot;) = &quot;Backed Up&quot; Then<br>...<br>End If<br><br>If both buttons had the same name and value, there would be no way to tell which one was pressed.&nbsp;&nbsp;Either they have to have different names, or different values. <p>ray<br><a href=mailto:rheindl@bju.edu>rheindl@bju.edu</a><br><a href= > </a><br>
 
thank you ray and guestg for sorting me out, guestg I'll look at the solution you mentioned. Anyway I've got it to work now so thankx.
 
What do u want to do further???<br>I eman after clicking on the buttons, what do u want to do?<br>What do u want to do with the knowing of wich buton was pressed?<br>U can call with the onclik event a fucntion that could do whatever you want, such as storing a value into a variable or something like that , and then u could request the value of this vaRIABLE.<br>Exoplain a little mopre of your purposes...<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top