On the JSP page, I have a drop down list. When the first element of the list is selected, I want the text area to be displayed right click. I am new to Javascript / Jquery, so I clearly don't see anything in this function (the text area never appears). Hope someone can help.
This is HTML:
<tr class="odd gradeX">
<td class="col-lg-3">
<div>
<label>Show text area</label>
<select id="show" class="form-control" name="show_text_area" onchange="change()">
<option value="1">YES</option>
<option value="0">NO</option>
</select>
</div>
</td>
<td class="col-lg-3">
<div>
<label>Text area</label>
<textarea id="text_area" class="form-control" type="text" name="text_area" placeholder="Write something" rows="5" cols="50" style="display: none"></textarea>
</div>
</td>
</tr>
This is the function above JSP:
<script> function change() {
var selectBox = document.getElementById("show");
var selected = selectBox.options[selectBox.selectedIndex].value;
var textarea = document.getElementById("text_area");
if(selected === '1'){
textarea.show();
}
else{
textarea.hide();
}
});</script>
source
share