You need to sign in to do that
Don't have an account?
msb-appsupport1.3905906418879758E12
How to check only one check box at a time using visualforce page?
Hi,
I am building a visualforce page associating with Apex code.
I have multiple checkboxes. And I want user to check only one checkbox at a time.
How could I do it?
I have tried some javascript associating with onclick feature, however, it doesn't work.
Thanks.
I am building a visualforce page associating with Apex code.
I have multiple checkboxes. And I want user to check only one checkbox at a time.
How could I do it?
I have tried some javascript associating with onclick feature, however, it doesn't work.
Thanks.
Try using Radio buttons instead of Checkboxes, gives more flexibility. Still if you need checkboxes, try using the following javascript
<input type="checkbox" class="radio" value="1" name="fooby[1][]" />
<input type="checkbox" class="radio" value="1" name="fooby[1][]" />
<input type="checkbox" class="radio" value="1" name="fooby[1][]" />
<script>
$("input:checkbox").click(function() {
if ($(this).is(":checked")) {
var group = "input:checkbox[name='" + $(this).attr("name") + "']";
$(group).prop("checked", false);
$(this).prop("checked", true);
} else {
$(this).prop("checked", false);
}
});
</script>