0
我自定義Bugzilla,我需要更新錯誤編輯頁面上其他註釋文本區域中的文本。該文本將需要根據用戶從下拉菜單中選擇的狀態動態更改。對於這個即時消息希望使用onChange事件。有沒有人有關於如何實施這個建議?如何使用JavaScript動態更新Bugzilla額外評論textarea?
我自定義Bugzilla,我需要更新錯誤編輯頁面上其他註釋文本區域中的文本。該文本將需要根據用戶從下拉菜單中選擇的狀態動態更改。對於這個即時消息希望使用onChange事件。有沒有人有關於如何實施這個建議?如何使用JavaScript動態更新Bugzilla額外評論textarea?
這裏是一個可以說明這樣做的一種方式的示例:
<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>
希望這有助於!
這似乎已經完成了技巧謝謝,現在唯一的問題是值是字符串,它將根據錯誤的狀態而改變。我會嘗試做一個開關案例或使用elsif語句爲每個狀態輸出正確的消息。 再次感謝 – user379222 2010-07-14 15:14:48