We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Accessing drop down options in plugin puzzles

Home Forums Puzzles Accessing drop down options in plugin puzzles

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #39156
    GLiFTeK
    Customer

    Hi,
    In the plugin section of the user manual is the instructions for setting up the XML/JS for drop down fields.

    But, there’s no instructions for retrieving/defining those options for use in the Provide function.

    I know for fields you should use like this:

    var myCheckbox = block.getFieldValue(‘myCheckbox’) === ‘TRUE’;

    That’s Boolean.

    I have:

    const myDropdown = block.getFieldValue(‘myDropdown’);
    And console log shows its value.

    However, when I go to use whatever option, I get error undefined.

    How do we go about defining each menu option?

    Could the staff add that please?
    And possibly give a tip here?
    Thanks! :good:

    #39290
    GLiFTeK
    Customer

    i found that i had to get the boolean result of each option before my provide fundction,
    ie:
    `
    let option1 = block.getFieldValue(‘myDropdown’) === “OPTION1”;

    let option2 = block.getFieldValue(‘myDropdown’) === “OPTION2”;

    let option3 = block.getFieldValue(‘myDropdown’) === “OPTION3”;
    `
    then pass those option1,2,3 as vars through the provide ( and the return)

    then within the provide function

    `
    let myDropdown;

    if (option1 == true){
    myDropdown = ‘myText1’;
    }
    else if (option2 == true){
    myDropdown = ‘myText2’;
    }
    else if (option3 == true){
    myDropdown = ‘myText3’;
    }
    console.log(‘myDropdown: ‘,myDropdown);

    `

    possibly there’s a more efficient way of doing it, but this works.
    i had to get a “definition” to the ‘myText’ i was using

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.