- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2014 03:58 PM
On one of our forms we have a checkbox that through a UI policy reveals a multiple choice variable with a set of options that are mandatory. The issue we are having is creating a client script to clear out that multiple choice option that was selected in the event the user unchecks the checkbox that allowed the multiple choice to be shown in the first place.
I tried to create a onChange client script to the checkbox and have attempted some recommended script I found through the community, however no matter how I tried to compare oldvalue and newvalue I could not get the script to clear the multiple choice.
I then tried to comment it all out and simply make it clear the multiple if any change occurred on the checkbox, which i thought would work, but once it was in production we found that this clear out the variable selection when the users try and work on the request.
Below is the current client script we loaded, with the commented fail attempts I tried before. If anyone could point out how to correctly accomplish this it would be most appreciated.
Thanks!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// if (isLoading || newValue == '') {
// return;
// }
//if (newValue == 'false' && oldValue == 'true'){
// }// g_form.clearOptions('project_systems');
g_form.setValue('project_systems', '');
//Type appropriate comment here, and begin script below
// }
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2014 07:49 PM
Hi,
Please do following.
First check using alert function in your code what is newValue when user change checkbox.
according to that you write your code. like.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
return;
}
if (newValue == false){
g_form.setValue('project_systems', '');
}
if(newValue == true){
// your code
}
}
if you want your code will work onload comment first if condition.
try it if you have any problem let me know.
Thanks,
Sanjeev Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2014 07:49 PM
Hi,
Please do following.
First check using alert function in your code what is newValue when user change checkbox.
according to that you write your code. like.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
return;
}
if (newValue == false){
g_form.setValue('project_systems', '');
}
if(newValue == true){
// your code
}
}
if you want your code will work onload comment first if condition.
try it if you have any problem let me know.
Thanks,
Sanjeev Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2014 08:29 AM
Thanks Sanjeev, it works now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2015 04:11 PM
I have a similiar problem. However, the set of checkboxes I am trying to clear are contained within a variable set. This code does not seem to clear it. I've tried adding variable.variable name but that didn't work either. Here is my code at the moment:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading ) {
return;
}
if (newValue == false){
g_form.setValue(variables.PAY_Sage_305, '');
}
if(newValue == true){
// your code
}
}
I have this set in a Catalog Client Script tied to a Catalog Item - referencing my Catalog and the variable name Payments. How it needs to work is we have separate variables for 4 groups - Payments, SBS, MMBS, Other. When one of these is clicked, it presents another group of checkboxes with options they can select. These latter are each contained within a variable set for that particular group. For instance - the Payments has a variable set called BRG PL Payments which contain the options associated with the Payments checkbox - PAY_Sage_305 is one of the variables within that variable set. If the user unselects the Payment checkbox after making selections within it, we want it to unselect those options, so if they were to check it again, PAY_Sage_305 would then be unchecked.