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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to uniquely identify a submit button

Status
Not open for further replies.

blexman

Programmer
Jul 18, 2001
34
0
0
CA
I have a main.asp driver program that checks what the NextAction is and based on this 'value' will call another program.

There are 4 pages each of which has a submit button with value='submit' (this is what the users want). So, I have 4 submit buttons and each has a value=submit. In the driver program I check this value and then call an update program.

How can I uniquely tell one submit button from another ?

thanks
hanton
 
By its name.

<input type=&quot;submit&quot; name=&quot;submit1&quot; value=&quot;Submit&quot;>

is what you would key on the page with the button. Then, assuming that it's in a form, on your driver page, you would then reference in VBScript:

if len(request.form(&quot;submit1&quot;) then
'Do something here
end if

HTH Insanity is merely a state of mind while crazy people have a mind of their own.
 
Yes that would work, however,

I am using a common name for all my buttons - NextAction - and then checking the values in the main driver.

Could I use a hidden value to set the name to submit1 ?

or could I qualify the button more uniquely by the form id ?

hanton
 
Not sure about using the form id (never needed to do it myself), but the hidden value should work just as well. Just use the same syntax, except you are referencing the hidden value.

<input type=&quot;hidden&quot; name=&quot;submit1&quot;> '(don't think you necessarily need a value in this case)

if len(request.form(&quot;submit1&quot;) then
'Do something here
end if

Just set the hidden value in each form to 1, 2, 3, etc. as your way to separate and recognise which page/form you are receiving the data from. HTH Insanity is merely a state of mind while crazy people have a mind of their own.
 
2 Things.

1. You can't use the ID and have it submit to the other page. I believe (and you may want to verify) that the ID is really only used in client side scripting.

2. You have a ability to see exactly what page submitted the form. In the servervariables collection, you can check where you are at and where you were. Just use that as a additional check to see which button the client used, becuase the value is already there wether you like it or not, and this way you dont have to build a hidden form value. The money's gone, the brain is shot.....but the liquor we still got.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top