473,756 Members | 3,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

prefill form action based on button pressed

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
7 2778
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
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******** ***********@new s.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
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
M
that must be some big stick up your butt.
"David Dorward" <do*****@yahoo. com> wrote in message
news:d0******** ***********@new s.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
M
well if anyone cares more about javascript than grammar and punctuation,
although a simple find, document.locati on.href does the trick.

<form method="post">

<input name="button.ed itStock" type="button" value="edit"
onclick="docume nt.location.hre f='#request.mys elf##xfa.edit#& mid=#attributes .mid#'">
|
<input name="button.de leteStock" type="button" value="delete"
onclick="docume nt.location.hre f='#request.mys elf##xfa.delete #&mid=#attribut es.mid#'">
|
<input name="button.pr intLabels" type="button" value="print labels"
onclick="docume nt.location.hre f='#request.mys elf##xfa.printL abels#&mid=#att ributes.mid#'">

</form>

thanks!

todays date: 03/05/05
"M" <m@m.com> wrote in message
news:pj******** ********@newsre ad1.news.pas.ea rthlink.net...
that must be some big stick up your butt.
"David Dorward" <do*****@yahoo. com> wrote in message
news:d0******** ***********@new s.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
M wrote:
well if anyone cares more about javascript than grammar and punctuation,
although a simple find, document.locati on.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
M wrote on 05 mrt 2005 in comp.lang.javas cript:
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1961
by: Robert V | last post by:
Hi all, I could use some help programming on of my Perl script to handle different submit buttons within the same form. Here is what I have so far. A user goes to a Web form and inputs some data into a textarea box. Below this box there are two buttons ... one that is labelled "Save & Exit" and other that is labelled "Save and Preview" On submit of either button, the form data is sent to the same perl script. What I need to have happen is...
15
6576
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and the buttons. The problem is when I post a form to itself, the Enter key will not submit the form, it only clears the contents of the text box. The only way I can submit is to click the submit button. Here is a simplified version of my code that I...
6
3106
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form should be submitted as if the button is pressed. Is this correct? Does this behaviour vary across browsers? Chris
5
8449
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform' action='ins_op.php' method='post'>"; lots of form stuff
4
9904
by: karenmiddleol | last post by:
I have the following form the user enters the From and to period and presses the Submit button and the form fields are cleared once the submit button is pressed. Is there a way I can keep the Form fields visible and not cleared. Also when I display the message I want the original form cleared in a different version of this page how can I clear the form completely when I display the data entered from the Response statements I do not...
19
2206
by: darrel | last post by:
On my vb.net page, I have 4 sets of inputs + form buttons. example: Search: (GO) Zip: (GO) County: (GO) County: (GO) The problem is if I go to the page, type in a zip code, and hit enter.
1
2253
by: Bill_W_Stephens | last post by:
I need a form with two buttons and ability to detect which button was pressed. I got this code to work using a javascript global variable, but I know there must be a better way using DOM. Any suggestions? <html> <head> <script language="JavaScript" type="text/javascript"> // global var: which button I am pressing var btnWhichButton;
9
4269
by: mosscliffe | last post by:
I am struggling to find a python example of the scenario - I have. I have a python script, which generates a page with a search button (actually an input field). The data from the above submissions is interrogated and the same script produces a new search option and the a page of results from the previous search request. - as done by Google's Main search page. The user then has the option of a new search or navigating to a
9
3029
by: phopman | last post by:
Hello! I am currently working on a project. And have been assigned to get up to speed quickly on php. And even though I love the language, it's not easy to get up to speed in like 2 seconds :-) The code I will list below is supposed to have four parts: 1. Not logged in. List up all text from the database. 2. Logged in. List up all text from the database. But now with an "edit" button, with the possibility to jump to number 3. 3. Logged...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.