I have a input type number. Once the user enters the number in that field. I want to generate that many input types under it. How can I do it with javascript or Ajax for that matter.
<table width="100%">
No of Plans:
<input type="text" name="numbers" value="" onkeypress="return isNumberKey(event)"/> //using AUI here to check if numbers only
//If the number is 5 say. I need to generate 5 input fields under here.
My Javascript which will check that the user enters only numbers is
<script type="text/javascript">
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
All this is working for me. I just need the loop which would generate input fields as the value entered in numbers.