Hi,
I have a form in which I have a drop down menu. I want to show/hide specific row(s) in a table based on the selection. Currently, it's partially working, because only one instance is showing/hiding. So I was wondering how to make it will with multiples instances. I guess I would have to loop around all the "document.getElementById" values ??
Here's my code
I have a form in which I have a drop down menu. I want to show/hide specific row(s) in a table based on the selection. Currently, it's partially working, because only one instance is showing/hiding. So I was wondering how to make it will with multiples instances. I guess I would have to loop around all the "document.getElementById" values ??
Here's my code
Code:
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form name="mainForm">
<select name="mainList" onChange="functionShowHide();">
<option value="0">A</option>
<option value="1" SELECTED>B</option>
<option value="2">C</option>
<option value="3">D</option>
</select>
</form>
<table>
<tr id="row">
<td>
Row 1
</td>
</tr>
<tr>
<td>
Row 2
</td>
</tr>
<tr id="row">
<td>
Row 3
</td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
var selectedValue = document.mainForm.mainList.options[document.mainForm.mainList.selectedIndex].value;
functionShowHide(selectedValue);
function functionShowHide(selectedValue) {
var selectedValue = document.mainForm.mainList.options[document.mainForm.mainList.selectedIndex].value;
if (selectedValue == "1") {
document.getElementById("row").style.display = 'none';
}
else {
document.getElementById("row").style.display = 'inline';
}
}
</script>
</body>
</html>