I have a dropdown list which has two options A and B. I wish to dynamically generate drop down menu with options A1, A2, A3 if the user selects A and B1 , B2, B3 if the user selects option B . I tried creating a select element and appending it to the document but everytime it gives some error.Am unable to create a select element. Can anyone please help me out ? Currently the code should generate select element on clicking on the submit button but it doesnot work.Please have a look.
<html>
<head>
<script type=”text/javascript”>
function showMethod()
{
var select1 = document.createElement(‘select’);
select1.setAttribute(‘name’,’A’);
select1.setAttribute(“size”,”1″);
var option1 = document.createElement(‘option’);
option1.setAttribute(‘value’,’1′);
var text1 = document.createTextNode(‘A1’);
option1.appendchild(text1);
select1.appendchild(option1);
document.getElementById(‘Form1’).appendchild(select1);
</script>
</head>
<body>
<form id = “Form1″ method=”get” >
<input type=”button” onclick=”showMethod()” value=”Submit” style=”position:absolute;left:449px;top:400px;z-index:76″ />
</body>
</html>
Thanks