firing dojo onchange based on value selected in combobox

时光总嘲笑我的痴心妄想 提交于 2019-12-12 00:34:08

问题


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
});


来源:https://stackoverflow.com/questions/19160346/firing-dojo-onchange-based-on-value-selected-in-combobox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!