Q:

How to add choice in mcq using javascript

I am trying to create program that able to create mcq. Below is my code
<p>how many mcq choice you need?</p>
<input type="text" id="question"></input>

Now im trying to use javascript to retrieve the input from the textbox. If the input is 4, it will appear

a
b
c
d

How would the javascript look like that i need to accomplish this?

A:

try this
<script type="text/javascript">

    function CreateMCQ(){
           document.getElementById('option').innerHTML = "";
           var input = document.getElementById('question').value ;
           for(var i = 0;i<input;i++){
               document.getElementById('option').innerHTML += "<input type='radio'>"+"option "+(i+1)+"<br/> ";
           }
       }
  </script>

html
    <p>how many mcq choice you need?</p>
    <input type="text" id="question"></input>
    <input type="submit" value="Create" onclick="CreateMCQ();" />
    <div id="option"></div>

