0

Bugzillaをカスタマイズしていますが、バグ編集ページの[追加コメント]テキスト領域のテキストを更新する必要があります。このテキストは、ユーザーがドロップダウンメニューから選択したステータスに応じて動的に変更する必要があります。このために私はonChangeイベントを使用したいと思っています。これを実装する方法について誰か提案がありますか?

4

1 に答える 1

0

これを行う1つの方法を説明する例を次に示します。

<html>
<head>
<script>
var messages = ['Message 0', 'Message 1', 'Message 2', 'Message 3', 'Message 4'];
function myOnChangeHandler(selectObj) {
    // if there are more elements with name="additional_info" then you should attach unique id to your text area and use getElementById instead
    var textAreaElement = document.getElementsByName("additional_info")[0]; 
    textAreaElement.value = messages[selectObj.selectedIndex];
}

</script>
</head>
<body>
<form>
<select id="continent" onchange="myOnChangeHandler(this);">
    <option value="0">Select a Continent</option>
    <option value="1">North America</option>
    <option value="2">South America</option>
    <option value="3">Asia</option>
    <option value="4">Europe</option>
  </select>
  Additional info:
 <textarea cols="80" rows="8" style="" name="additional_info"></textarea> 
</form>
</body>
<html>

これがお役に立てば幸いです。

于 2010-07-14T13:52:23.403 に答える