
July 19th, 2005, 07:28 AM
|
|
|
Can a form have two POST locations? Workarounds?
Is it possible to POST a FORM to multiple URLS at the same time....OR....
Is the only workaround for this scenario to use response.redirect in the
called ASP page and do a multi processing?
- Jason
|

July 19th, 2005, 07:28 AM
|
|
|
Re: Can a form have two POST locations? Workarounds?
While you can use client side code to change the action of your form, I
personally stay away from relying on client side code for such things.
What I would do instead is:
<form method="post" action="page.asp">
<form stuff here>
<input type="submit" name="cmdSubmit" value="Delete Users">
<input type="submit" name="cmdSubmit" value="Disable Users">
Then, in page.asp:
sSubmit = UCase(Request.Form("cmdSubmit"))
Select Case sSubmit
Case "DELETE USERS"
''the code that you currently have in pagea.asp
Case "DISABLE USERS"
''the code that you currently have in pageb.asp
Case Else
''if you'd like a default action that will hopefully
''need to fall back on - see below
End Select
The problem with this method though is that if you have a designer who
doesn't like the values of your submit buttons and changes them, you
will have to be aware of this and update your code accordingly. So, the
other method, which will rely on the name of the submit button instead
of the value would be:
<form method="post" action="page.asp">
<form stuff here>
<input type="submit" name="cmdDelete" value="Delete Users">
<input type="submit" name="cmdDisable" value="Disable Users">
Then in page.asp:
If Request.Form("cmdDelete") <> "" Then
''the code that you currently have in pagea.asp
End If ''or else if you prefer
If Request.Form("cmdDisable") Then
''the code that you currently have in pageb.asp
End If
This, again though, if your designer renames the submit buttons, you'll
have to be aware of this, or have a default action to fall back on.
And now the other thing, if you've read this far, is that if your user
presses enter to submit the form (or Ctrl+M), neither of these values
will be present, so you will have to have either have a default option,
which could either run your code, or redirect back with an error that
says "Please click on the action you'd like to take." or something along
those lines.
When I use two submit buttons, I'll normally use instr instead of a full
comparison anyway, like:
sSubmit = UCase(Request.Form("cmdSubmit"))
Select Case True
Case Instr(sSubmit, "DELETE") > 0
'code
Case Instr(sSubmit, "UPDATE") > 0
'code
Case Else
'default
End Select
Or, you could not do the ucase and do a text comparison:
Instr(sSubmit, "delete", 1), then it wouldn't matter if it's DeLeTE,
delete, DELETE, or anything else.
Ray at work
"jason" <jason@catamaranco.com> wrote in message
news:elQX5dRXDHA.2632@TK2MSFTNGP09.phx.gbl...[color=blue]
> Is it possible to POST a FORM to multiple URLS at the same time....OR....
>
> Is the only workaround for this scenario to use response.redirect in the
> called ASP page and do a multi processing?
>
> - Jason
>
>[/color]
|

July 19th, 2005, 07:28 AM
|
|
|
Re: Can a form have two POST locations? Workarounds?
Many thank Ray!
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eAEZqgRXDHA.2620@TK2MSFTNGP09.phx.gbl...[color=blue]
> While you can use client side code to change the action of your form, I
> personally stay away from relying on client side code for such things.
> What I would do instead is:
>
> <form method="post" action="page.asp">
> <form stuff here>
> <input type="submit" name="cmdSubmit" value="Delete Users">
> <input type="submit" name="cmdSubmit" value="Disable Users">
>
> Then, in page.asp:
>
> sSubmit = UCase(Request.Form("cmdSubmit"))
> Select Case sSubmit
> Case "DELETE USERS"
> ''the code that you currently have in pagea.asp
> Case "DISABLE USERS"
> ''the code that you currently have in pageb.asp
> Case Else
> ''if you'd like a default action that will hopefully
> ''need to fall back on - see below
> End Select
>
>
> The problem with this method though is that if you have a designer who
> doesn't like the values of your submit buttons and changes them, you
> will have to be aware of this and update your code accordingly. So, the
> other method, which will rely on the name of the submit button instead
> of the value would be:
>
> <form method="post" action="page.asp">
> <form stuff here>
> <input type="submit" name="cmdDelete" value="Delete Users">
> <input type="submit" name="cmdDisable" value="Disable Users">
>
> Then in page.asp:
>
> If Request.Form("cmdDelete") <> "" Then
> ''the code that you currently have in pagea.asp
> End If ''or else if you prefer
>
> If Request.Form("cmdDisable") Then
> ''the code that you currently have in pageb.asp
> End If
>
>
>
> This, again though, if your designer renames the submit buttons, you'll
> have to be aware of this, or have a default action to fall back on.
>
> And now the other thing, if you've read this far, is that if your user
> presses enter to submit the form (or Ctrl+M), neither of these values
> will be present, so you will have to have either have a default option,
> which could either run your code, or redirect back with an error that
> says "Please click on the action you'd like to take." or something along
> those lines.
>
>
>
> When I use two submit buttons, I'll normally use instr instead of a full
> comparison anyway, like:
>
> sSubmit = UCase(Request.Form("cmdSubmit"))
>
> Select Case True
> Case Instr(sSubmit, "DELETE") > 0
> 'code
> Case Instr(sSubmit, "UPDATE") > 0
> 'code
> Case Else
> 'default
> End Select
>
> Or, you could not do the ucase and do a text comparison:
> Instr(sSubmit, "delete", 1), then it wouldn't matter if it's DeLeTE,
> delete, DELETE, or anything else.
>
>
> Ray at work
>
>
>
> "jason" <jason@catamaranco.com> wrote in message
> news:elQX5dRXDHA.2632@TK2MSFTNGP09.phx.gbl...[color=green]
> > Is it possible to POST a FORM to multiple URLS at the same[/color][/color]
time....OR....[color=blue][color=green]
> >
> > Is the only workaround for this scenario to use response.redirect in the
> > called ASP page and do a multi processing?
> >
> > - Jason
> >
> >[/color]
>
>[/color]
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|