473,396 Members | 2,055 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.

2 buttons in a html form

61
Hi guys,

I got a html form which calls itself when clicked:

Expand|Select|Wrap|Line Numbers
  1. <% 
  2.     // This code deals state ADD_MORE_TRACKS
  3.     if(state == ADD_MORE_TRACKS || state == -1)
  4.     {
  5.         out.println("Please add your track listing");
  6. %>
  7. <form method="post" action="input.jsp">
  8.     <table>
  9.         <tr><td>Track Name:</td> <td><input type="text" name="title" size="20"></td></tr>
  10.         <tr><td>Track Time:   </td> <td><input type="text" name="time" size="20"></td></tr>
  11.         <tr><td>Track Rating:   </td> <td><input type="text" name="rating" size="20"></td></tr>
  12.         <tr><td><input type="submit" name = "moreElement" value="Add More Element"></td> <td><input type="button" name="finishedButton" value="Finish"></td>  </tr>
  13.     </table>
  14. </form>
  15. <% }    
  16. %>
  17.  
  18.  
The form has 2 button. One is "submit" which when clicked will get the values from the textfiled and pass it onto my variables I declared above (not shown in the code above), however when i click on my 2nd button, it should let me change state so I can process what I have entered.

I just want to know how i can get to know when the 2nd "finished" button has been clicked in jsp.

Thanks heaps.
Sep 14 '09 #1
2 1926
r035198x
13,262 8TB
You are going about JSPs the wrong way.
You should have no Java code inside JSPs these days.
Sep 14 '09 #2
Frinavale
9,735 Expert Mod 8TB
You need to use the Request Object.

The Request Object contains information about the page request... It is to get the values that the client passes to the web server during an HTTP request.

The Request Object will tell you which button caused the page to submit. You do this using the Request Object's getParameter() method.

For example:
Expand|Select|Wrap|Line Numbers
  1.     if( request.getParameter( "moreElement" ) != null ) {
  2.         // they clicked moreElement
  3.     } else if( request.getParameter( "moreElement" ) != null ) {
  4.         // they clicked moreElement
  5.     }
Sep 21 '09 #3

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

Similar topics

1
by: KS | last post by:
I write my html pages as .jsp files (java server pages). The final result when the page is rendered in the browser, and I do a view source, is nothing less the normal HTML codes. The problem is I...
3
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via...
1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
0
by: Klaus Jensen | last post by:
Hi! This has been annoying me for a while now, and I can't get it to work It is really driving me nuts! Basicly this simple webapp created to illustrate my problem, renders five buttons, and...
5
by: Edwinah63 | last post by:
Hi everyone, i was wondering if anyone else had observed this and if there is any workaround or patch. i have some screens (an mdi child forms) with the buttons &Add, &Edit, &Save and E&xit,...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
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...
1
by: Paddy | last post by:
The problem I am facing is as follows: I am populating an HTML table on my webpage with rows of data from a database. The rows may be sometimes 10 and sometimes say,3. I have two buttons on that...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
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: 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
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
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
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...

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.