- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 04:01 AM
Hi,
I am a newbie and not too good in scripting.
I am creating a Catalog item and there I have 2 check boxes, I want that only one can be selected at a time.
I know this can be done if I create radio buttons but I have been specifically asked to create checkboxes.
This is the onChange Client Script on function variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == true){
g_form.setValue('menu','false');
}
This is the onChange Client Script on menu variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == true){
g_form.setValue('function','false');
}
Can anyone help with the script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 05:56 AM
Last try,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == true || newValue == 'true'){
alert("inside if");
g_form.setValue('menu', false);
}
}
//this is onchange client script on menu variable
if(newValue == true || newValue == 'true'){
alert("inside if");
g_form.setValue('fuction', false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 06:19 AM
Can you mark my answer as correct/helpful and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 05:59 AM
Prabhmeet is right! When coding for checkboxes in a catalog item, a checkbox variable takes a javascript boolean (so true or false, without quotations).
It looks like you've spelt "function" wrong in your latest post of the code for the menu script. Probably should be:
g_form.setValue('function', false); instead of 'fuction'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2019 06:23 AM
You could use two onChange scripts - one for "Menu" and the other for "Function". Below is an example of the script you can use in the "Menu" onChange script that will make "Function" read-only:
if (newValue == 'true') {
g_form.setDisabled('function', true);
//This allows the end-user to change their selection on the form (if applicable).
} else if (newValue == 'false') {
g_form.setDisabled('function', false);
}
This same script can be applied to the onChange script for "Function", but it would use 'menu' (instead of 'function').