- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:21 AM
Hi Everyone, I'm trying to write a simple onChange client script that clears values based on an answer:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue==='') {
return;
}
if(g_form.getValue('relation_to_employee').indexOf("child") == -1) {
g_form.clearValue('x_dnf_gw_found_type_of_child');
g_form.clearValue('x_dnf_gw_found_dependent');
}
}
So if Relation to Employee does not equal "child" then I want to clear the values for Type of Child and Dependent fields. This works fine, but the Relation to Employee drop down has "-- None --'" and for some reason, this doesn't work. I've tried changing my if statement to the following but it still doesn't work:
if(g_form.getValue('relation_to_employee', '!=','child') || g_form.getValue('relation_to_employee','')){
Any suggestions on how to fix this? Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:26 AM
The option of "--None--" has a value of "". If you change your script to this it should work;
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if(g_form.getValue('relation_to_employee').indexOf("child") == -1) {
g_form.clearValue('x_dnf_gw_found_type_of_child');
g_form.clearValue('x_dnf_gw_found_dependent');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2018 09:43 AM
You can try,
var relemp=g_form.getValue('relation_to_employee');
alert('Relation to emp is '+relemp);
if(relemp=='' || relemp!='child'){
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.