[英]how to update second select based on first select box in chosen prototype javascript?
[英]how to fire onchange event in chosen prototype javascript select box?
我正在使用选择的原型选择框。 现在我想在该选择框上触发onchange事件。 这是选择原型的链接
这个怎么做。 请帮我。
<script type="text/javascript" src="/js/Event.simulate.js"></script>
<script src="/js/prototype.js" type="text/javascript"></script>
<script src="/chosen/chosen.proto.js" type="text/javascript"></script>
<div class="side-by-side clearfix" style="margin-bottom:14px;">
<select data-placeholder="Select Loacation" class="chzn-select" tabindex="2" name="source">
<option value="">Select Loacation</option>
<option value="">option1</option>
<option value="">option2</option>
</select>
</div>
Event.observe($(".chzn-select"),'change', function(){
//alert($(".chzn-select").chosen());
})
Event.observe($(".chzn-select"),'change', function(){
类名可以多次使用,因此从$$()
返回一个数组,这是一种使用数组的方法。
$$(".chzn-select").invoke('observe', 'change', function() {
...
});
我之前没有使用过选择; 它的说明说它需要进行设置,因此您可能必须在更改事件之外执行此操作。
document.observe('dom:loaded', function() {
$$(".chzn-select").each(function(select) {
new Chosen(select);
});
});
在选择框对象上使用“addEventListener”方法。
编辑 - 这是一个例子:
document.getElementById('selecboxid').addEventListener('change', SomeFunction(), false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.