473,395 Members | 1,797 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,395 software developers and data experts.

Multiple Submit buttons on a form - Which one pressed

-- When you press one of the submit buttons the SetYesNo onclick function starts first & sets the value of the hidden form variable at the bottom (vReviewButton).
--

Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. function SetYesNo(YN)
  3. {
  4. theForm.vReviewButton.value = YN;
  5. }
  6. </script>
  7.  
  8.  
  9. -- Next, the onsubmit function is started (after the button's onclick) to show the value of the button
  10. --
  11.  
  12. -- After the form's onsubmit is run the action redirects to the next html/asp step
  13. --
  14.  
  15. <script LANGUAGE="JavaScript">
  16. function Chk()
  17. {
  18.    if (theForm.vReviewButton.value == "Yes")
  19.    {
  20.    alert("You pressed Yes");
  21.    }
  22.  
  23.    if (theForm.vReviewButton.value == "No")
  24.    {
  25.    alert("You pressed No");
  26.    }
  27. }
  28. </script>
  29.  
  30. <form method="post" onsubmit="return Chk(this)" name ="theForm">
  31. <input type="submit" value="Yes" name="vReviewButtonYes" 
  32. onclick="SetYesNo('Yes')"/>
  33.  
  34. <input type="submit" value="No" name="vReviewButtonNo" 
  35. onclick="SetYesNo('No')"/>
  36.  
  37. <input type="hidden" name="vReviewButton" value=""/>
  38. </form>
_____________________________

Is it conveluted - YES - but it was driving me crazy & I found a simple solution (I like simple) that works with javascript
Mar 11 '11 #1
1 1496
Dormilich
8,658 Expert Mod 8TB
I doubt the form will submit …
Mar 12 '11 #2

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

Similar topics

2
by: sandyde2 | last post by:
Hi all, I get the tough problem and expect to get help.. In a html page, I dynamically created many forms which named as NO+business_id. In each form there are two submit buttons to...
2
by: J. B. Moreno | last post by:
Is it possible to detect inside an onsubmit event /which/ button was pushed? I searched google and saw lots of suggestions for alternatives, but nobody outright saying it was impossible. At this...
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...
2
by: rudranee | last post by:
hello, How do i declare multiple submit buttons on a form? and how do i come to know on the next page which button has been clicked? Can i do it in JSP page? Please tell me.
2
by: fliss | last post by:
Hello I have four submit buttons on my page - each carrying a value which refreshes the page selects from my db and displays the results in the drop down. The prob is i would like another...
0
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2)...
7
by: aashishn86 | last post by:
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
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...
0
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,...

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.