473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

7 New Member
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 6261
Dormilich
8,658 Recognized Expert Moderator Expert
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
41059
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 sure how to do it in javascript <form name="form1" method="post" action="myNewplace.asp" ONSUBMIT="return ValidateData();"> <input type="Submit" name="Submit" value="Save" >
8
14647
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 the form. If submit button2 is pressed I need to make sure that only textfied1 is filled before submitting the form.
6
3106
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 should be submitted as if the button is pressed. Is this correct? Does this behaviour vary across browsers? Chris
4
4134
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 finding the answer in previous posts - I have already seen this question answered numerous times in this forum, only problem is that the recommended method is not available to me :-(. I know that if I could code an onclick event on the <input...
4
9905
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 Form fields visible and not cleared. Also when I display the message I want the original form cleared in a different version of this page how can I clear the form completely when I display the data entered from the Response statements I do not...
3
2604
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 in the bulleted list on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons. One for Submit, Reset and Exit. If submit is pressed page should be validated and submit (insert into
5
1935
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 image, the submit happens automatically to the server. Heres my problem: I have two event handlers for both these buttons as stated below: BUTTON 1:
6
2154
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 identifies this?
1
4552
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 iframe to save file in the Db and come back to parent page with file name in the form of the parent , so that i can save the parent after updaing other details. I am able to save the file in the DB and come back to parent page. While coming back...
0
9619
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
9454
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
10261
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
10103
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...
0
9911
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
7460
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
6713
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();...
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.