[Solved] IF THEN ELSE

0

Hi, I’m thinking Java Script might be the answer here… I’d like to show the value for this question a form;

[question(“value”), id=”6″]

However, sometimes the value is intentionally blank. How could I do something like;

IF [question(“value”), id=”6″] IS BLANK THEN “The code is blank”, ELSE [question(“value”), id=”6″]

Alex Walker asked

    Best answer

    1

    You should be able to do something like:

    var value = ‘[question(“value”), id=”6″]’;

    if (!value) return false;

    //do stuff

    In the first line you’re writing the value of that merge code to var value.

    In the second line you will have an if statement that checks to see if there is no value (undefined or null), and if there isn’t a value return false to break the function

    If the condition does not pass (there is a value), instead carry on with the rest of the function (! acts as a negation in Javascript). The `if (value)` checks to see if there is a value, `if (!value)` checks to see if there isn’t a value.

    Noel Black answered
      0

      Brilliant, many thanks!

      Alex Walker answered
        ×

        Login

        Question stats

        • Active
        • Views2956 times
        • Answers2 answers
        • Followers0 followers