I am customising Bugzilla and I need to update the text in the Additional Comments text area on the bug editing page. This text will need to be changed dynamically depending on which status the user selects from the drop down menu. For this I'm hoping to use the onChange
event. Has anyone any suggestions on how to implement this?
Here is an example that may illustrate one way of doing it:
<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>
Hope that this helps!