473,699 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple buttons on a form

The ASP page has multiple buttons, and when the user clicks different
buttons, it will submit the form data to different URLs.

My first approach was to use BUTTON type, and triggers javascript function
to submit the form data. However, it didn't work properly and I changed to
use SUBMIT type.

<INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page"
onClick="action 1()">

function action1()
{ //etc...
document.myform .action = "main.asp"
document.myform .submit();
}

OR

<INPUT TYPE="SUBMIT" NAME="action1" VALUE="Return to Main Search Page"
onClick="action 1()">

function action1()
{ //etc...
document.myform .action = "main.asp"
}

So which is the appropriate way? please advise. thanks!!
Jul 23 '05 #1
2 2105
Matt wrote on 06 jul 2004 in comp.lang.javas cript:
The ASP page has multiple buttons, and when the user clicks different
buttons, it will submit the form data to different URLs. My first approach was to use BUTTON type, and triggers javascript
function to submit the form data. However, it didn't work properly and
I changed to use SUBMIT type.

<INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page"
onClick="action 1()">

function action1()
{ //etc...
document.myform .action = "main.asp"
document.myform .submit();
}

OR

<INPUT TYPE="SUBMIT" NAME="action1" VALUE="Return to Main Search Page"
onClick="action 1()">

function action1()
{ //etc...
document.myform .action = "main.asp"
}

So which is the appropriate way? please advise. thanks!!


There is no "appropriat e way".
In programming you can have your personal preference.

If you use the submit-button then I would use

<form action="main.as p" method="post">
<input type="submit" name="actions" value="action1" >
<input type="submit" name="actions" value="action2" >

and have serverside ASP[vbs] find out what action you want to accomplish:

if request.form("a ctions")="actio n2" then response.redire ct "act2.asp"

==============

but clientside coding is possible [to prohibit submission, par example]:

<form onsubmit="retur n myAction()" action="main.as p" method="post">
<input type="submit" name="actions" value="action1" onclick="a=1">
<input type="submit" name="actions" value="action2" onclick="a=2">
<input type="submit" name="actions" value="action3" onclick="a=3">

where, when action() returns false, the submit will not be carried out:

function myAction()
// no submit if a=1
return (a!=1)
}

not tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
Matt wrote:
The ASP page has multiple buttons, and when the user clicks
different buttons, it will submit the form data to different URLs.

My first approach was to use BUTTON type, and triggers javascript
function to submit the form data.
This is a fragile solution; where js is not available, does the form
do anything? This is generally best done server side.
it didn't work properly and I changed to use SUBMIT type.

<INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search
Page" onClick="action 1()">

OR

<INPUT TYPE="SUBMIT" NAME="action1" VALUE="Return to Main Search
Page" onClick="action 1()"> So which is the appropriate way?


Since the button that does not do anything, I'd choose input
type="button", which has no default behavior. It looks like the form
just gives someone a new page, so a simple text link is probably best.
But if the form does something else, how about this?:

<INPUT TYPE="SUBMIT" NAME="action1"
VALUE="Return to Main Search Page" onClick="action 1()">

Then use javascript to change the behavior, e.g., return false
onSubmit and do something else. That makes it transparent to the user.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #3

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

Similar topics

2
1852
by: Matt | last post by:
The ASP page has multiple buttons, and when the user clicks different buttons, it will submit the form data to different URLs. My first approach was to use BUTTON type, and triggers javascript function to submit the form data. However, it didn't work properly and I changed to use SUBMIT type. <INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page" onClick="action1()">
2
3145
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as they want. If they need to add more, they click an "add name" button and the javascript inserts another row of input boxes. Each row should have two radio buttons to indicate sex (M F). When you have multiple text input boxes with the same...
0
2700
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main form. Then I have 3 pages on a tab control ( 4 if the type of candidate validates that is is to be shown) Each page has a subform. The subforms can be either single or continuous, I think I am still deciding what I want to lock down this entry...
3
2560
by: D. Shane Fowlkes | last post by:
Sorry for the length of this post. I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: http://www.drpt.virginia.gov/temp1.gif All the fields on this form have validation controls on them so they can not submit the form unless all fields are completed and some fall within a specified numeric range. When the form first is loaded,...
8
579
by: TJS | last post by:
what are folks doing to get around limitation of one server form per page ?
7
3105
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
5
20014
by: Alex Maghen | last post by:
In ASPX 2.0 with MasterPages and all that, my entire page only has one actual <FORM>. But there are several different sections of the page that provide what are functionally separate forms with separate Submit buttons. In basic HTML, I can have multiple forms on a page and the browser knows that if any of the fields for Form A have the focus, then pressing ENTER will send a Click to the submit button for Form A. Same for Form B, etc. ...
5
14124
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
4
2077
by: ApexData | last post by:
I have a continuous form that has Allow- Add/Edit/Del set to False, so that the form is in View mode only. I have New/Edit/Del buttons in the form header. My New & Edit buttons work as a like. My Del button works great also, but for one record at a time only. In ViewOnly mode, the user is able to highlight a single record to delete using the RecordSelector, press the DelButton and it works fine. However, if multiple records are...
2
6946
by: 6afraidbecause789 | last post by:
Hi - Has anyone ever used toggle buttons to select items in a listbox? I'd like to put about 24 toggle buttons on an unbound form that select or deselect items in a multiple select listbox. I've come across a way to set the listbox value to only 1 at a time, but need multiple toggle buttons to be on their corresponding listbox item values to be selected. Thanks!
0
8622
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
9184
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...
1
8930
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
7767
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
5878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4382
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...
1
3062
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
2
2359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2013
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.