• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP page with buttons

 
JC Bismark
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to design a Member.jsp page showing the writing "Fan Club" and two buttons "Add New" and "Delete".Each button will invoke different jsp pages:
"Add New" invoke JSPMemberDetails.jsp
"Delete" invoke JSPMemberList.jsp

I understand that in case of one button "Add New" in the page the action attribute will refer to the JSPMemberDetails.jsp destination.

How we create it in case of two buttons? do I put the two input tags (for buttons)in the same form, in that case there are both refer to the same page JSPMemberDetails.jsp .Please,advise...

Using Eclipse IDE,my jsp page with one button:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the submit handler for the form, check which button invoked the handler and set the form's action accordingly.
 
JC Bismark
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bear,

Can you be more specific about the handler?

Thanks
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by JC Bismark:
Hello Bear,

Can you be more specific about the handler?

Thanks


This talks about the handler Bear was speaking of. You'll need to use the technique as Bear suggested and determine which button triggered it.

You can also use the buttons onclick handler to help with this. Something like this.
 
JC Bismark
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg,

I'm not familiar with javascript, so by using the onClick event handler
<FORM onSubmit="alert(button + pressed")">


</FORM>
-How we use it within the form?I tried to write it like this but it within the form but it don't let me: input type="submit" onClik = "button=this.value" VALUE="Add New"
this other one is the same with VALUE="Delete"
- How we deal with the ACTION attribute? knowing that the 2 buttons go to two different jsp pages destination?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic