473,788 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two actions on a form

Hello,

I can't do two actions wich must be done on a form having two buttons.
(payment by invoice and payment by Credit card)

The first action establishes a link on two differents pages according
to whether one wants to pay by invoice or credit card. (2 buttons send)
The second action is for check if all the fields were filled.
The two codes are ok by themselves but do not work together!

For the first action (links) I have:

<script language='Javas cript'>
function setAction(name) {
if (name=="submit1 ")
document.forms[0].action= "invoice.ph p"
else if (name=="submit2 ")
document.forms[0].action= "credit_card.ph p"
}
</script>

and on the form:
<input type="submit" id="submit1" name="submit1"
onClick="setAct ion(this.name)"
<input type="submit" id="submit2" name="submit2"
onClick="setAct ion(this.name)"
....

and for the second action (check fields) :

<script type="text/javascript">
function verif_fields()
{
if(document.for m1.name.value == "")
{
alert("Write your name");
document.forml. name.focus();
return false;
}
if(document.for m.email.value == "")
{
alert("Write your email.......
....
return confirm("ok");
}
</script>

and in the form:
<form name="form1" method="post" onSubmit="retur n verif_fields()" >

I try to do like this but it doesn't work! :

<script type="text/javascript">
function verif_fields()
{
if(document.for ml.name.value == "")
{
alert("Write your name");
document.forml. name.focus();
return false;
}
if(document.for ml.email.value == "")
{
alert("Write your email ...
....
document.form1. action = button==1? "invoice.ph p" : "credit_card.ph p";
return confirm("Ok");
}
</script>

and in the form :

<form name="forml" method="post" onSubmit="retur n verif_fields()" >

<input type="submit" id="submit1" name="submit1" onClick="button =1"
value="Invoice" >
<input type="submit" id="submit2" name="submit2" onClick="button =2"
value="Credit card">

Is somebody can help me? Thanks, pascal

Nov 9 '06 #1
1 1554
elia wrote:
I can't do two actions wich must be done on a form having two buttons.
(payment by invoice and payment by Credit card)
No, it mustn't. Give the buttons a control name (typically the same) and
the one used to submit the form will be successful. That is, its control
name and value will be added to the data set sent to the server. You can
then determine the necessary processing server-side.

It may not be a good idea to have two submit buttons in this case.
Instead, consider using radio buttons or a select element to allow the
user to choose between methods.

Relying on scripting is not a good idea at the best of times. Doing it
with e-commerce solutions is utterly stupid: the idea is to get money
from people, and one cannot do that if the site doesn't work.

[snip]

Mike
Nov 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1613
by: Kay Schluehr | last post by:
Hi all, thanks for Your attention ! I think my proposal was more in mind of Rons modified exec than Pythons lambda. When George proposed his unpacking behavoir for list-comps as a pack of suggar:
1
1734
by: Sophisticado | last post by:
Hi Newbie here. I am trying to have two form actions on submission using a javascript. The first calls a php class (http://www.blah.org/test.php) and the second adds data to a mySQL database via a php function call (<? php echo $editFormAction; ?>. Both actions work; however, only the second action in the fucntion runs. Here is the code: <script language=javascript> <!--
1
2301
by: ammarton | last post by:
Hello all...I'm a bit new to working with Macros in Access so forgive me if the terminology I use is not accurate. To preface this, basically I am using a form on a replicated database so the end-user can filter on a specific report they want to see. This database was designed by my predecessor (of which he left no documentation) and I need to add some additional functions to this end-user filter report. Within one Macro, he has over...
1
1069
by: Perra | last post by:
If I create a form, set Opacity to some thing like 50%, set TopMost = True, set CausesValidation = False, I will get a transparen form that is transparent for keyboard action. (You can work with the window showing through the transparent form.) But it does not get transparent for mouse action. Does any one know how to achieve that. So that my form get totaly transparent for all kind of actions?
1
1510
by: genojoe | last post by:
In Microsoft Access, I use Application.Echo False ......code that causes form to flash Application.Echo True to hide intermediate actions while a form is visible. I cannot find an equivalent command in VB.Net. Specifically, I am changing tabs on the form and I see significant flashing before reaching the final view.
9
14750
by: Mark | last post by:
I have a lengthy form (i.e., many inputs) on my form.php page. What's different about this form than many others I've created is that I want the user to have a choice of submitting this form data to one of two pages, choice1.php or choice2.php, both of which read $_POST data from the form. Obviously, a 'submit' button will send the user to the page specified by the form's 'action=' setting, so I would have to employ some sort of trick....
8
4794
by: yawnmoth | last post by:
Say I have the following HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="">
5
2011
by: Tyrone Slothrop | last post by:
I have created a form which has two submit buttons. The first is a preview button to view the data they have entered into a formated page. The second actually submits the data for saving. The two submit buttons have onclick events defined for both the targets and actions. These are both working OK. However, I have an onsubmit event in the form tag which validates the data which is also triggered when the preview button is clicked. I...
6
2723
by: Sarvananda | last post by:
I have two forms: 1. Donor 2. Patron I want to bring the two forms together in a tab control on separate pages. I had some startup actions to be triggered for each form. Which event in the tab control page should I use for these? The onLoad event was what I was using when these forms were independent. Now as subforms on the tab control, the OnLoad event is triggered when the main form is loaded. This creates a problem and new records...
0
9656
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
9498
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
10370
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
10177
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...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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

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.