Skip to main content
Inspiring
February 19, 2022
Answered

ComboBox change event - HTML Canvas

  • February 19, 2022
  • 1 reply
  • 182 views

Trying to get a simple alert to show the value of the selected option in a combobox.  The alert is showing, but not the value.

 

if(!this.cb_change_LensMagCombo_1) {  // where this.cb is your combobox

function cb_change(evt) {

// Start your custom code

alert(evt);  // use switch/case or multiple if-statments

// End your custom code

}

$("#dom_overlay_container").on("change", "#LensMagCombo_1", cb_change.bind(this));

this.cb_change_LensMagCombo_1 = true;

}

 

 

Also, I have  six similar comboboxes.  Would would be an efficient way to do that code.  The comboboxes have different values.  

    This topic has been closed for replies.
    Correct answer kglad

    use:

     

     

    alert(evt.target.value);  

     

    assign a listener to each combobox.  they could all call the same function, but depending on what you're doing with the values, it may not shorten your code much and certainly will not appreciably affect performance.

     

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    February 19, 2022

    use:

     

     

    alert(evt.target.value);  

     

    assign a listener to each combobox.  they could all call the same function, but depending on what you're doing with the values, it may not shorten your code much and certainly will not appreciably affect performance.