0

我正在为黑莓使用 Webworks,我无法在设备上触发更改,在涟漪中它就像一个魅力,但在设备中,更改事件不会触发......希望 some1 可以帮助我

HTML

<select name="motherCat" onchange="motherChanged(event)">
    <option value="0">option0</option>
    <option value="1">option1</option>
    <option value="2">option3</option>
</select>

<select id="subCategory">
    <option value="0">wait mother change to fill</option>
</select>

Javascript

function motherChanged(event){
    alert("motherChanged");
    var retCategory =subcategories[event.target.value];
    var fin = retCategory.length;
    var slCat = $('subCategory');
    slCat.length = 0;
    for(var i = 0;i<fin;i++){
        slCat.options.add(new Option(retCategory[i].text,retCategory[i].value));
    }
}
4

2 回答 2

0

问题在于您如何设置onchange属性。event未定义。而是使用将被定义的东西:

<select name="motherCat" onchange="motherChanged(this)">

this参数将是选择元素本身。当然,你也可以有一个不接受参数的函数,然后你可以省略this.

于 2012-01-30T16:20:39.217 回答
0

你也可以使用

<select name="motherCat" onchange="motherChanged">

JavaScript 应该以事件作为参数调用函数。

于 2012-02-23T22:31:16.160 回答