You need to sign in to do that
Don't have an account?
Aruna
Selecting Single check box on VF Page
Hi All,
Happy New Year ,
I have a requirement; under page block table I am displaying all the contacts with the check box.
But the problem is I need to allow user to select only one check box.
I think this need to be done using JavaScript function, can anyone have help me by sending sample code.
Thank you.
Would it be possible to use a radio button group instead? That would save you some effort!
Otherwise, you could give all of the checkboxes a class, then use jQuery's class selector (jQuery(".className")) to find the elements and set their value to false. Do this in a javascript function, and call that from the onClick event of each checkbox to clear them all, before settin gthe current box to checked.
Hi MattLacey,
Thank you for the replay.
Could you please send me if you have sample code.
You can also acheive this with html code, here is sample snippet (which might not be perfect but which will help you to get started the code)
Presuming you've already included jQuery in your page from a static resource you'll want to do something like this:
And then do your inputCheckboxes something like:
This code may not be 100% correct as I've typed it straight into the browser, but you can see how it'll work and it should start of you off down the right path.
Hi,
You can use the below code snippets for reference
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.