I am trying to create radio buttons in a container. The total number of radio buttosn is supplied from the value selected in Combobox that is in another container, when I am trying to do this, I am getting only 1 radio button displayed even the supplied number is more than 1, also I am getting those appended to the previous selection buttons, instead of that I need to clear the contents when the selection is changed and new number of buttons should only be displayed.
$(document).ready(function(){
$("#choice").change(function(){
var radio_name=$("#choice option:selected").text();
var a=$("#choice option:selected").val();
var element=$('<input type="radio" name='+ radio_name +'/><br>');
for(i=1;i <= a;i++){
element.prependTo('#reports');
}
});
});
</script>
</head>
<body>
<div style="padding-top:20px;padding-left: 300px;color: orange;">
Select Your Choice: <select id='choice' style="width:100px;">
<option>Select Your Choice</option>
<option value="4">Sales</option>
<option value="2">Income</option>
<option value="3">Consumer</option>
<option value="5">Exports</option>
</select>
</div>
<div id="reports" style='float: left;padding-top: 100px;color:orange;'>
</div>