[SOLVED]deselect the checkbox of usergroup element

samani

Member
hi
i have usergroup element in my form and i want to deselect one of groupname after load the form.
what JS code need to do that?
thank you
 
We use the JHtml API to build that control, so it doesn't work like most Fabrik elements. You'll need to directly access the checkbox in the DOM. The ids are asdsigned by J!, but should be of the form !group_X, where X is the group ID. But it is possible that it might be 2group_X, if you have mroe than one usergroup control on the form.

So something like ...

Code:
jQuery('#1group_16').prop('checked', false);

-- hugh
 
Yeah, you'll probably have to add it in your own load event in a ./components/com_fabrik/js/form_X.js file (replace X with your numeric form ID), as because it's a J! control, I don't think we actually add it as a Fabrik form element. Something like ...

Code:
$( document ).ready(function() {
   jQuery('#1group_8').prop('checked', false);
});

However, if you are needing to restrict what groups people can select, you might want to use something other than the usergroup element. I typically use a join to #__usergroups, with a where clause that restrict them to selecting within a parent group ("WHERE parent_id = 123"), or exclude certain IDs ("WHERE id NOT IN (x,y,z)", or only allow certain ID's ("WHERE id IN(x,y,z)").

-- hugh
 
i use this code and resolve

jQuery( document ).ready(function() {
jQuery('#1group_8').prop('checked', false);
});

thank you hugh...
 
i use this code and resolve

jQuery( document ).ready(function() {
jQuery('#1group_8').prop('checked', false);
});

thank you hugh...
Oops, sorry, yes, jQuery, not $. I've been doing some work in a native jQuery module recently, and got used to using $.

Sent from my HTC6545LVW using Tapatalk
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top