BlackBerry WebWorksの変更
-
12-11-2019 - |
質問
私はBlackBerryのWebWorksと一緒に働いています。 何人か1が私を助けることができることを願っています
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));
}
}
解決
onchange
プロパティを設定する方法にあります。event
は未定義です。むしろ定義されるものを使う:
<select name="motherCat" onchange="motherChanged(this)">
.
this
パラメータは選択要素自体になります。もちろん、パラメータを受け入れる機能もあり、this
を省略することもできます。
他のヒント
を使うこともできます
<select name="motherCat" onchange="motherChanged">
.
とJavaScriptは、イベントをパラメータとして関数を呼び出す必要があります。