client script display info in textfield
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 07:18 AM - edited 02-28-2024 07:27 AM
Hello.
I want this client script to display "0" in a text box when the user has the role "admin" and has checked the checkbox "choice_1".
The checkbox is in a variable set in my catalog item where this client script is.
Currently my script is not working and i dont know why. any tips?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var accessLevel = g_form.getValue('user_role');
var A0 = g_form.getValue('choice_role.choice_1');
if(accessLevel.includes('Admin') && A0 == true) {
g_form.setValue('pris_vis', "0");
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 08:01 AM
Hello @asd22
Try below script -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return; }
try {
var accessLevel = g_form.getValue('user_role');
var A0 = g_form.getValue('choice_role').choice_1;
if (accessLevel.includes('admin') && A0) {
g_form.setValue('pris_vis', "0");
} else {
g_form.setValue('pris_vis', "");
}
} catch (error) {
gs.error('Client script error: ' + error);
}
}
if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
CB