如何使用JavaScript动态更新Bugzilla附加注释文本区域? [英] How to use JavaScript to dynamically update the Bugzilla Additional Comments textarea?

查看:64
本文介绍了如何使用JavaScript动态更新Bugzilla附加注释文本区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自定义Bugzilla,并且需要更新Bug编辑页面上其他注释"文本区域中的文本.需要根据用户从下拉菜单中选择的状态来动态更改此文本.为此,我希望使用onChange事件.有没有人建议如何实现这一目标?

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 im 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>

希望这会有所帮助!

这篇关于如何使用JavaScript动态更新Bugzilla附加注释文本区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆