Skip to main content
Known Participant
March 6, 2013
Answered

ComboBox related conditional

  • March 6, 2013
  • 1 reply
  • 580 views

Hi there!

Prior to trigger an action with a button I want to warn user he/she must select an item in a ComboBox named "CBSCH".

Item at index 0 of the ComboBox has no data attached and label is "Please, select a school".

Example;

searchBtn.onRelease = function() {

    var school = CBSCH.selectedIndex;

    if (school = 0) {

        errorMsgFld.html = true;

        errorMsgFld.htmlText = "<font color='#FF0000'>Please, select a school.</font>";

    }

    else {

        searchFct();

    }

};

This doesn't work. What's wrong.

I also used selectedItem.data = ""

Wrong too.

I thank you in advance for your help!

This topic has been closed for replies.
Correct answer kglad

use the double equal (==) to test for equality:

searchBtn.onRelease = function() {

    var school = CBSCH.selectedIndex;

    if (school == 0) {

        errorMsgFld.html = true;

        errorMsgFld.htmlText = "<font color='#FF0000'>Please, select a school.</font>";

    }

    else {

        searchFct();

    }

};

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 6, 2013

use the double equal (==) to test for equality:

searchBtn.onRelease = function() {

    var school = CBSCH.selectedIndex;

    if (school == 0) {

        errorMsgFld.html = true;

        errorMsgFld.htmlText = "<font color='#FF0000'>Please, select a school.</font>";

    }

    else {

        searchFct();

    }

};

Germaris1Author
Known Participant
March 6, 2013

PERFECT!

It works nice and smooth...

Thank you very much, kglad.

kglad
Community Expert
Community Expert
March 6, 2013

you're welcome.