• Resolved sonny123

    (@sonny123)


    Hi,

    I have a dropdown field, fieldname9, with text-value pairs like a-300, b-200, and c-100, and I want to do something based on whether certain characters are present in an option or the vt/text.

    I’ve tried:

    * if (fieldname9.options[fieldname9.selectedIndex].text.indexOf(“a”) == -1) do something;

    * if (fieldname9.text.indexOf(“a”) != -1) do something;

    * if (fieldname9.vt.indexOf(“a”) != -1) do something;

    * if (fieldname9.value.indexOf(“3”) != -1) do something;

    But all of them break the function, and I’ve tested to see if it wasn’t the do something that was the problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @sonny123,

    Thank you so much for using our plugin.

    The process is simpler. The |v modifier in the field’s name gives you access to the vt attribute in the option selected. So, the code would be:

    if(fieldname9|v.indexOf('a') != -1) do something;

    or using regular expression:

    if(/a/i.test(fieldname9|v)) do something;

    Best regards.

    Thread Starter sonny123

    (@sonny123)

    That’s perfect, thank you!

    Great plugin btw.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Select Dropdown Option Based on Characters’ is closed to new replies.