Hello javascript experts, I’ve been stuck on this code for few days with no idea how to fix it. I have a textfield where user can put in a value. When the value is submitted a number of dropdown lists will be generated by the inputted value. However I'm not too sure what went wrong with the code but it seems there is no response after you submit the value.
Following is my current code:
Javascript:
<script type="text/javascript">
function getvalue() {
var number = document.getnumber.input.value;
document.getElementById('result').value = number;
}
function generatedropdown() {
while (i < number)
{
document.write
(
<select name="list">
<option>1</option>
<option>2</option>
</select>
);
i++;
}
}
</script>
HTML:
<form name="getnumber">
Input number: <input type="text" name="input">
<input type="button" value="Next" onclick="getvalue()">
</form>
<form name="showdropdown">
Number entered: <input type="text" id="result" readonly="readonly">
<input type="button" value="Show lists" onclick="generatedropdown()">
</form>
EDIT: Sorry I'm a bit noobie at Javascript. I have moved function generatedropdown() to the body tags and now I get some feedback after submitting. However I'm still abit confuse in turning the string into a statement.