473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

multiple submit buttons

hi !
how can i use multiple submit buttons in the same form

i want to pass form values to different pages depending on which of the two submit button is clicked...
thank's
Mar 27 '09 #1
7 4376
well i achieved that by using this code i found :

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language="JavaScript">
  2. function OnSubmitForm()
  3. {
  4.   if(document.pressed == 'Insert')
  5.   {
  6.    document.myform.action ="insert.html";
  7.   }
  8.   else
  9.   if(document.pressed == 'Update')
  10.   {
  11.     document.myform.action ="update.html";
  12.   }
  13.   return true;
  14. }
  15. </SCRIPT>
  16.  
  17.  
  18. <FORM name="myform" onSubmit="return OnSubmitForm();">
  19.  
  20. <INPUT TYPE="SUBMIT" name="Operation" onClick="document.pressed=this.value" VALUE="Insert">
  21.  
  22. <INPUT TYPE="SUBMIT" name="Operation" onClick="document.pressed=this.value" VALUE="Update">
  23.  
  24. </FORM> 
now the problem is i need to call the validate function as well OnClick
how do i get around this
Mar 27 '09 #2
jhardman
3,406 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. <INPUT TYPE="SUBMIT" name="Operation" onClick="validate();document.pressed=this.value" VALUE="Update">
  2.  
You can also put all of that functionality within the validate function. This is really more of a javascript question, if you are going to keep the thread going, we should move it to that forum now.

Jared
Mar 27 '09 #3
well i tried that..........it didn't work...
yups, please move it....
thank's...
Mar 27 '09 #4
Expand|Select|Wrap|Line Numbers
  1. onsubmit="return (onsubmit() && validate(this));"
  2.  
i used this for that..........
Mar 30 '09 #5
acoder
16,027 Expert Mod 8TB
You should avoid using reserved words, e.g. onsubmit for function names. Some browsers may start complaining. You could also call the onsubmitform function within validate(). There's also no need to return from the function because it always returns true.
Mar 31 '09 #6
hi
writing onsubmit within validate didn't work for me... don't know why..
other points noted...
thank's..
Mar 31 '09 #7
acoder
16,027 Expert Mod 8TB
In validate(), just before return true at the end, just add:
Expand|Select|Wrap|Line Numbers
  1. OnSubmitForm();
  2. return true;
then your onsubmit event would be simply:
Expand|Select|Wrap|Line Numbers
  1. <form ... onsubmit="return validate(this);">
(you could always avoid this too and use unobtrusive JavaScript, of course).
Mar 31 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
3
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: ...
5
by: Lau Lei Cheong | last post by:
Hello, Let's say that I have multiple submit buttons on a form (imagebuttons actually, but documentations say that <input type=image> which a called image buttons should behave like submit...
1
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine...
5
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...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
5
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
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all I have the following code: I am trying to use the value of the image button to evaluate what plan the user has chosen, i.e. it request("submit1")="Basic", then the user chose basic plan...
9
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...
3
by: printline | last post by:
Hello All I have a form with multiple submit buttons, where i would like to open in a new window when hitting one of the submit buttons. Can't seem to figure this out according to the code i'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...
0
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...
0
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...

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.