firing dojo onchange based on value selected in co

2019-08-17 06:09发布

问题:

When calling dojo.wipein and dojo.wipeout from buttons, everything works great. But calling them based on the value in a combobox: I can't do it. Does anyone know how to make calling client side script depend on the value of a combobox?

In other words, if I change the combobox to "Yes", fire dojo.wipein, if I change the combobox to "No", fire dojo.wipeout.

EDIT: Thank you everyone for your help. Here is the code that worked. I am a beginner in javascript, which might show, but it works.

var comboValue = dojo.byId("#{id:comboBox1}").value
if (comboValue == 'Yes'){
dojo.fx.wipeOut({node:'Lewiston',duration:400}).play();
}else if (comboValue == 'No'){
dojo.fx.wipeIn({node:'Lewiston',duration:400}).play();
}else{
alert("the value is neither yes nor no!")
}

回答1:

In your Client Side JavaScript, use the following function:

dojo.byId("#{id:FieldID}").value

Where Field ID is the ID property of your XSP object. This will calculate out the full rendered ID of the element and return its value to use in your client script.



回答2:

try

   onKeyUp: function(evt){
        if (this.value == 'Yes'){
            //dojo.wipein       
        }else if this.value == 'No'){
            //dojo.wpieout
        }else{
            //others
        }
    }


回答3:

dojo.connect(myComboBox, 'onChange', function (evt) {
    var value = myComboBox.get("value");
    if(value == "1")
         // do one thing
    else
         // do the other thing
});