• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I want to submit the button but not refresh the page

 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am stuck with a problem. I have 3 buttons,

<html:submit disabled="false" property="action" styleId="btn1"> Button 1 <html:submit>
<html:submit disabled="false" property="action" styleId="btn1"> Button 2 <html:submit>
<html:submit disabled="true" property="action" styleId="btn1"> Button 3 <html:submit>

When the user clicks the first button, it should disable the first button, enable the third button and also i need to pass to the java code which button is clicked.

I am using javascript to disable and enable buttons. but when i do this, it does disable the button, but also refreshes the page , so the button is enabled again.

and if it executes the javascript, it doesn't tell me which button was clicked, as when it refreshes the page, the button is unclicked.

Please help me solve this problem
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I answered this in a different thread already.

Use html:button instead of html:submit on the buttons that you do not want to "refresh".
 
sudhakar Tadepalli
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rao, You need to track enable or disbale value with scriplet. You can try decalring a property in the form bean as boolean or string and chek in in the jsp and pass the value to the html.

EX:

<% boolean tempValue = formBean.getClickedValue(); %> //Line 1

<html:submit disabled="<%tempValue%>" property="action" styleId="btn1"> Button 1 <html:submit>


When submitted you get the value and set it to the formBean in your action class, so when it comes to the same page your first line exceutes again and keeps the previous value. Hope it helps.

Sudhakar
 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot both of you. Marc you did tell me before, but I think i did somethign wrong then and it didn't work. I am sorry to bother you again, it works this time
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by meera rao:
Thanks a lot both of you. Marc you did tell me before, but I think i did somethign wrong then and it didn't work. I am sorry to bother you again, it works this time


Ah, "it works": the words I love to hear!
 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry I posted the reply in hurry.

I used html:button, but i would also like to know which button was clicked, and this does not happen with html:button.

How would i know which button was clicked?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic