how to use dependent set a value

how to use dependent set a value

tomcat_nz@hotmail.comtomcat_nz@hotmail.com Posts: 11Questions: 4Answers: 0

editor1.dependent( 'option', function ( val )
{
if (val === 'value1' || val === 'value2')
{
return {show: ['field1', 'field2', 'field3']};
}
else
{
return {hide: ['field1', 'field2', 'field3']};
}
} );

in the code above I need to set a specific value to field1 how can I do?
Sam

This question has an accepted answers - jump to answer

Answers

  • tomcat_nz@hotmail.comtomcat_nz@hotmail.com Posts: 11Questions: 4Answers: 0

    More information I mean the value of field1 can vary on the value of option.
    Sam

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited August 2020 Answer ✓

    Hi Sam,

    You can set the value of a field using the values`` option in the returned JSON object as described in thee-api dependent()` documentation. e.g.:

    return {
      show: [‘field1’, ‘field2’, ‘field3’],
      values: {
        field1: ‘MyValue’
      }
    };
    

    Allan

  • tomcat_nz@hotmail.comtomcat_nz@hotmail.com Posts: 11Questions: 4Answers: 0

    Thanks it helps me understand how to use code.

  • tomcat_nz@hotmail.comtomcat_nz@hotmail.com Posts: 11Questions: 4Answers: 0

    Your guide is very usefull I can solve my problem with these part of code. But in case of select (have multiple values) how to set of hide some values in select. Please guide me. Thanks

This discussion has been closed.