473,396 Members | 1,940 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.

What submit button was pressed? Same form, another page (JSP)!

Later edit:

Too complex:

The only thing I should know is:
The submit button's NAME (and value) will only be sent if that particular button was used to submit the form, so you should be able to check that in the server side script.

Rest is history:


Hello to everybody. I'm new in everything and I need your help.

How can I checked what submit button was pressed?

I have something like this:

form
input - I collect info


submit button1 GOTO to page1.jsp for processing the info using formula 1
submit button2 GOTO to page1.jsp for processing the info using formula 2


I tried something like this:

Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2.     <HEAD>
  3.         <TITLE>Using Buttons</TITLE>
  4.     </HEAD>
  5.  
  6.     <BODY>
  7.         <% 
  8.  
  9.         String s = request.getParameter("buttonName") ***********************************************************
  10.  
  11.         %>
  12.  
  13.         <FORM NAME="form1" METHOD="POST">
  14.             <INPUT TYPE="HIDDEN" NAME="buttonName">
  15.             <INPUT TYPE="BUTTON" VALUE="Button 1" ONCLICK="button1()">
  16.             <INPUT TYPE="BUTTON" VALUE="Button 2" ONCLICK="button2()">
  17.         </FORM>
  18.  
  19.         <SCRIPT LANGUAGE="JavaScript">
  20.             <!--
  21.             function button1()
  22.             {
  23.                 document.form1.buttonName.value = "button 1"
  24.                 form1.submit()
  25.             }    
  26.             function button2()
  27.             {
  28.                 document.form1.buttonName.value = "button 2"
  29.                 form1.submit()
  30.             }    
  31.             // --> 
  32.         </SCRIPT>
  33.     </BODY>
  34. </HTML>
  35.  
This is example witch I found on the internet, but in my case I need the know what button was pressed in ANOTHER page(not the same), so I put the line with the stars in the page1.jsp (where I process the info), but the value of the string is null.
So.. Can you help me?:)
Aug 10 '09 #1
1 6223
Dormilich
8,658 Expert Mod 8TB
wouldn’t it make more sense if you process formula1/2 within the server script?

back to your question, the basic difference between the buttons are the buttons itself (sounds complicated?).
you only need one attribute in each of the buttons, that is different between those (could be anything, but id and name would be the obvious ones)

@abcdriver
definitely a server side issue. there’s no communication between two pages without the server.
Aug 10 '09 #2

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

Similar topics

2
by: jb | last post by:
Hello, I need to know which button was pressed in the submit , i tried reading the vaule of submit it the validateDate function but it returns 'undefined' value ; I do this in asp all the time, Not...
8
by: Syed Ali | last post by:
Hello, I have 1 HTML form with 4 submit buttons and 10 textfield entry areas. If submit button1 is pressed I need to make sure that all 10 textfield entries have been filled before submitting...
6
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...
4
by: actionwoman63 | last post by:
Dear all I need to be able to check which one out of two submit buttons within the same form was pressed in a javascript function prior to form submission. And before I get flamed for not...
4
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...
3
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary...
5
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
6
by: stellstarin | last post by:
I have a HTML page containing two submit buttons in the same form.When the form is submitted,I want to know through which submit button the form was submitted. Is there any event or property which...
1
by: IframeLearner | last post by:
Hi , I am trying to upload a file from a parent.jsp using Iframes. From Parent page. I have to save Subject, Desc, File and file name. to upload the file i am using Iframe. I want the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
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...

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.