Two Laptop Bag
The moose likes JSF and the fly likes Button action depending on checkbox selection. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Button action depending on checkbox selection." Watch "Button action depending on checkbox selection." New topic
Author

Button action depending on checkbox selection.

Robert Liguori
Author
Ranch Hand

Joined: Nov 27, 2007
Posts: 426
If a checkbox is not checked in JSF, I wish to open up a javascript warning when the commandButton is pressed.

How do I do this?


Robert J. Liguori - OCA Java SE 7 Programmer I Study Guide (Exam 1Z0-803)
Karanjit Singh
Greenhorn

Joined: Oct 17, 2010
Posts: 15
Just use normal javascript to do this as follows:

if(!document.getElementById(idOfCheckBox).checked)
{
alert('Check Box Not Selected');
return false;
}
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: Button action depending on checkbox selection.
 
Similar Threads
how to set checked to checkbox and radio button
html:checkbox
Applet Project
disabling text field after clicking on the checkbox
Readonly Checkbox