HTML button questions

Status
Not open for further replies.

E3

Ars Centurion
387
If not IsEmpty(Request.Form("GoSearch")) Then

Is the above code correct for checking if a button is pressed???


I have a form in an asp page. When its submitted, its calling another asp file to process it. But before doing so, since there are more then a buttons on the previous form, I use the above code to check whether its the correct button being depressed .

Somehow the loop for checking the buttons is not working and no action is perform.

[This message was edited by E3 on February 23, 2002 at 03:44.]
 
E3,

I'm not sure if ASP post/get's button names/values as form variables, but if you're up against a wall, I have another idea for you (it's what I usually do).

Typically, I add a hidden variable (call it "bType") to the form and in my buttons I add a JavaScript onSubmit="" statement that alters the value of the hidden variable to reflect what button was pressed.
So when the page you're calling gets the form information, it can check the Request.Form("bType") variable for what action it has to perform.

Either that or have the onSubmit in each button change the action value of the form to another page to handle the specific action.

I know it's not quite the answer you asked for, but maybe it'll help.

Jher
 

Aeirould

Ars Tribunus Angusticlavius
7,535
Subscriptor
Assuming you mean VBScript/ASP:

If Request.Form("GoSearch")="on" Then

for checkboxes and for command buttons:

HTML part:
code:<HR>
Code:
<input type="submit" name="Mode" value="Go Search">

<input type="submit" name="Mode" Value="Do Some Other Thing">

VB/ASP part:
Code:
Select Case Reqeust.Form("GoSearch")
   Case "Go Search"
      ' Do Whatever
   Case "Do Some Other Thing"
      ' Do Whatever
   Case Else
      ' Do Whatever
End Select

IsEmpty should in theory work, but with VBScript's notoriously weak typing it seems to make an assignment to a zero length string as part of the Request.Form(xxx) operation, thus making the variable *not* empty.
 
Status
Not open for further replies.