how to set prefix text

rajibosss11
Tera Contributor

HI I have a requirement Like Filed names : Check in Field name : checkin Name 

if Checkin is Yes the CheckinName field should fill with ("Today_")

if Checkin is No then CheckinName field should fill with ("Tomorrow_")

How to archive this in catalog onchange script .

1 REPLY 1

Vishal_Jaiswal
Mega Guru

Hi @rajibosss11 ,

Please follow the steps below to get the solution.

 

- Create onChange client script on checkin variable.

- Use below script

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    // Check the value of the 'checkin' variable
    // Note: Ensure 'Yes' and 'No' match the *Values* (not labels) of your choices
    if (newValue == 'Yes') {
        g_form.setValue('checkinname', 'Today_');
    } 
    else if (newValue == 'No') {
        g_form.setValue('checkinname', 'Tomorrow_');
    }
    else {
        // Optional: Clear the field if the value is neither Yes nor No
        g_form.clearValue('checkinname');
    }
}

 

Regards,

Vishal