select in 3 posistion

select in 3 posistion

rrzavaletarrzavaleta Posts: 78Questions: 52Answers: 2
edited March 2015 in Editor

I am using the example of

https://editor.datatables.net/examples/api/dependentFields.html

But I have the need to do 3 states in the select

I could not make the comparison of these three states.

{
                label: "Show options:",
                name: "options",
                type: "select",
                options: [ "1", "2","3" ],
                def: "3"
            },


ditor.dependent( 'options', function ( val ) 
    {   
    return val === '1' ?
            { show: ['position', 'office'] }:
            { hide: [ 'extn', 'start_date', 'salary'] } ;
            
    return val === '2' ?
            { show:[ 'extn', 'start_date', 'salary'] }:
            { hide: ['position', 'office']  } ;
    
    return val === '3' ?
            { hide: [ 'extn', 'start_date', 'salary','position', 'office']  } ;
    }

I'm planning to do the same process but with more ..but fields compared to the example I served 3

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    edited March 2015 Answer ✓

    You have three different return statements and only the first will actually return. You need to use a simple if condition.

    if ( val === 1 ) {
      return {
       show: ...,
       hide: ...
      };
    }
    // etc
    

    Allan

  • rrzavaletarrzavaleta Posts: 78Questions: 52Answers: 2

    Thanks allan my problem was the "return"

This discussion has been closed.