By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,625 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,625 IT Pros & Developers. It's quick & easy.

prefill form action based on button pressed

P: n/a
M
i have a form which i would like to input different "action" url depending
on the button that was clicked.

is there a way that javascript can prefill a defined action based on the
button pressed?

thanks!!!
Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
M wrote:
i have a form which i would like to input different "action" url depending
on the button that was clicked.

is there a way that javascript can prefill a defined action based on the
button pressed?


Not safely. The easiest way to do this is to have your form handler (i.e.
the thing you have at the HTTP resource you reference in the action) look
at which submit button was clicked (give your submit buttons the same name,
then see which value makes it though) and then act accordingly.

BTW - is your shift key broken?

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2

P: n/a
M
no my shift key is not broken. do you have a problem reading all lowercase?
"David Dorward" <do*****@yahoo.com> wrote in message
news:d0*******************@news.demon.co.uk...
M wrote:
i have a form which i would like to input different "action" url
depending
on the button that was clicked.

is there a way that javascript can prefill a defined action based on the
button pressed?


Not safely. The easiest way to do this is to have your form handler (i.e.
the thing you have at the HTTP resource you reference in the action) look
at which submit button was clicked (give your submit buttons the same
name,
then see which value makes it though) and then act accordingly.

BTW - is your shift key broken?

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

Jul 23 '05 #3

P: n/a
M wrote:
no my shift key is not broken. do you have a problem reading all
lowercase?


Most people find sentences that don't conform to the standard rules of
grammer harder to read then those that do. Additionally, the convention on
Usenet is not to place content in reverse chronological order.

http://www.netmeister.org/news/learn2quote2.html#ss2.3

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #4

P: n/a
M
that must be some big stick up your butt.
"David Dorward" <do*****@yahoo.com> wrote in message
news:d0*******************@news.demon.co.uk...
M wrote:
no my shift key is not broken. do you have a problem reading all
lowercase?


Most people find sentences that don't conform to the standard rules of
grammer harder to read then those that do. Additionally, the convention on
Usenet is not to place content in reverse chronological order.

http://www.netmeister.org/news/learn2quote2.html#ss2.3

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

Jul 23 '05 #5

P: n/a
M
well if anyone cares more about javascript than grammar and punctuation,
although a simple find, document.location.href does the trick.

<form method="post">

<input name="button.editStock" type="button" value="edit"
onclick="document.location.href='#request.myself## xfa.edit#&mid=#attributes.mid#'">
|
<input name="button.deleteStock" type="button" value="delete"
onclick="document.location.href='#request.myself## xfa.delete#&mid=#attributes.mid#'">
|
<input name="button.printLabels" type="button" value="print labels"
onclick="document.location.href='#request.myself## xfa.printLabels#&mid=#attributes.mid#'">

</form>

thanks!

todays date: 03/05/05
"M" <m@m.com> wrote in message
news:pj****************@newsread1.news.pas.earthli nk.net...
that must be some big stick up your butt.
"David Dorward" <do*****@yahoo.com> wrote in message
news:d0*******************@news.demon.co.uk...
M wrote:
no my shift key is not broken. do you have a problem reading all
lowercase?


Most people find sentences that don't conform to the standard rules of
grammer harder to read then those that do. Additionally, the convention
on
Usenet is not to place content in reverse chronological order.

http://www.netmeister.org/news/learn2quote2.html#ss2.3

--
David Dorward <http://blog.dorward.me.uk/>
<http://dorward.me.uk/>
Home is where the ~/.bashrc is


Jul 23 '05 #6

P: n/a
M wrote:
well if anyone cares more about javascript than grammar and punctuation,
although a simple find, document.location.href does the trick.


It might "do the trick", but it doesn't so what you actually asked for. And
it won't do the trick when a user who doesn't have a browser with
JavaScript available and enabled turns up - which is why I suggested taking
a more sensible approach when I responded to your original message. For
some reason you decided to ignore the solution to your question in favour
of treating my post script as an invitation to make a personal attack on
me.

Since it seems that your real problem seems to be about making a button act
as a link, you should probably look into CSS instead ... and create a link
that looks like a button.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #7

P: n/a
M wrote on 05 mrt 2005 in comp.lang.javascript:
todays date: 03/05/05


Please do not toppost and please do not use ambiguous statements.

For me today is 05/03/2005 [to many others it even is 06/03/2005]

Best would be using something like 2005/03/05

If you must say 03/05/05,
not stating your residence [possibly] being in the US is a bad idea.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.