I have created a dropdown which has values from 1 to 6(need to add more). In that html i have created a blank table and a form .
what i am tryin to do is ..when i select value 1 from dropdown , i want form of id 1 should be appended to table
and when i select value 2 form with the value of 2 should be appended not any other
Till now what is happening when i select the drop form added to html table but it is not visible
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table border ="1" align='center'>
<tr>
<td>
<select id="colors" onchange="changedesc()">
<option value="1">Desc1</option>
<option value="2">Desc2</option>
<option value="3" >Desc3</option>
<option value="4">Desc4</option>
<option value="5">Desc5</option>
<option value="6" >Desc6</option>
</select>
</td>
</tr>
</table>
<table id ="addform">
<!-- to be inserted here the div-->
</table>
<form id=1 style="visibility: hidden;">
<input type="text">
<textarea>abc</textarea>
</form>
<form id=2 style="visibility: hidden;">
<input type="text">
<input type="checkbo">
</form>
</div>
<script>
function changedesc(){
var eID = document.getElementById("colors");
var colorVal = eID.options[eID.selectedIndex].value
if (colorVal=="1"){
var frm = document.getElementById(1);
frm.removeAttribute("style");
var ff = document.getElementById("addform")
ff.appendChild(frm);
}
if (colorVal=="2"){
var frm = document.getElementById(2);
frm.removeAttribute("style");
var ff = document.getElementById("addform")
ff.appendChild(frm);
//how to remove previuos one
}
}
</script>
</body>
</html>