Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Nasir on Mar 14, 2008 03:45
open dhtmlx forum
how to submit combo when hitting the enter button???

Hi,

I want to submit the combo box when i hit the enter button. How do i do that?

i tried with the following code but it doesn't work.

var serienummerCombo=dhtmlXComboFromSelect("serienummer");
serienummerCombo.enableFilteringMode(true, "loadComboSerienummer.php");
serienummerCombo.attachEvent("onKeyPressed", function(e){
     if (!e) var e = window.event;
     if (e.keyCode == 13) {
    var state = serienummerCombo.DOMelem_hidden_input2.value;//state is true if input doesnt exist & false if exist in the list
    if (state){
     document.form2.submit();
    }else{
     alert('bla');
    }
    }
    });

this code worked with the previous version of the combobox but i have upgraded to v1.2. How do i get this to work with the new version?

Nasir
Answer posted by Support on Mar 17, 2008 08:32
In the latest combo version, "onKeyPressed" event handler gets as a parameter the keyCode, not the event.
Please, try to use the following:

serienummerCombo.attachEvent("onKeyPressed", function(keyCode){
    if (e.keyCode == 13) {
        var state = serienummerCombo.DOMelem_hidden_input2.value;//state is true if input doesnt exist & false if exist in the list
        if (state){
            document.form2.submit();
        }else{
            alert('bla');
        }
    }
});