When I click on another, the previous should not be visible.
I want that if I select A, and then B, and then C, the inner HTML should show C content only. Can someone help me with how to do this?
I actually need it for a jsp form where I can toggle between the options and then get parameter. I am stuck on this.
function myFunction() {
if (document.getElementById("abcid").selectedIndex == "1") {
document.getElementById("aid").innerHTML = "A:<select>" +
"<option>Select-</option>" +
"<option>Alex</option>" +
"<option>Jack</option>" +
"</select>";
} else if (document.getElementById("abcid").selectedIndex == "2") {
document.getElementById("bid").innerHTML = "B:<select>" +
"<option>Select-</option>" +
"<option>US</option>" +
"<option>Australia</option>" +
"<option>India</option>" +
"</select>";
} else if (document.getElementById("abcid").selectedIndex == "3") {
document.getElementById("cid").innerHTML = "C:<select>" +
"<option>Select-</option>" +
"<option>Blue</option>" +
"<option>Green</option>" +
"<option>Red</option>" +
"</select>";
}
}
<table>
<tr>
<td>ABC:
<select id="abcid" onchange="myFunction()">
<option>Select-</option>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
</td>
</tr>
<tr>
<td id="aid"></td>
</tr>
<tr>
<td id="bid"></td>
</tr>
<tr>
<td id="cid"></td>
</tr>
</table>