关于select下拉框的问题
<select name= "selectindex " onchange= "return change(); " >
<option value = "1 "> 修改意见 </option>
<option value = "2 "> 已确认 </option>
</select>
我有这么一个下拉框,如上代码所示,我现在想实现选择 "修改意见 "的时候产生一个文本域,如下所示
<p> 修改信息: <br />
<textarea name= "textarea "> </textarea>
</p>
而当选择 "已确认 "的时候不产生这个文本域,请问如何实现?我用Javascript写不出来 请各位大侠赐教 谢谢
------解决方案-------------------- <script>
function change(){
var sel = document.form_name.selectindex;
var v = sel.options[sel.selectedIndex].value;
if(v == 1) document.getElementById( "div_id ").style.display= "block ";
else if (v == 2) document.getElementById( "div_id ").style.display= "none ";
}
</script>
<form name= "form_name ">
<select name= "selectindex " onchange= "change(); " >
<option value = "1 "> 修改意见 </option>
<option value = "2 "> 已确认 </option>
</select>
<div id= "div_id " style= "display:none; ">
修改信息: <br />
<textarea name= "textarea "> </textarea>
</div>
</form>