Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JS confirm for h:commandButton??

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I would like for a user to confirm that he/she wants to undertake a submit action. I have a h:commandButton and I would like to use the JS confirm function and the onclick attribute in order to do that. The problem is when I want to submit the form (once the user has clicked yes on the confirm button) and I do not want to hard-code the path to the form. Another problem is that I have several h:commandButtons on the form.
Can anyone please help?
Thanks in advance,
Julien Martin.

My code

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was given the solution by someone. Here it is:

Julien.
 
Ronald Aguilar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can use this:

------------------------------------------------
on.click="return confirmationSave()"

------------------------------------------------


<script type="text/javascript">

function confirmationSave() {

var answer = confirm("Confirm Save")

if (answer == true){
return true;
}else{
return false;
}

}
</script>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic