javascript - non repeating number from a range and submitting from a form to a page -
can please please?
i'm needing select non repeated random number range of 1 - 80 not repeat it. rather form getting range user wish define in java script , @ press of submit button generates non repeated number in range of 1 - 80 in text area form submit, clear , result text area.
here form code:
<form name="generate"> <table> <tr> <td colspan="2"><input type="button" name="send_it" value="enter" onclick="chooserandom(this.form)"> <input type="reset" value="clear" onclick="clearform(this.form)"><br /> <br /> </td> </tr> <tr> <td>random number: </td> <td><input type="text" name="result" size="5"></td> </tr> </table> </form>
here java script:
<script type="text/javascript"> function chooserandom(form) { var m = parseint(form.lower.value); var n = parseint(form.upper.value) - m; var output = math.floor(math.random() * n) + m; if (m < 0) { alert('enter # greater 0'); } if (n > 79) { alert('enter # less 80'); } form.result.value = output; } // clears form function clearform(form) { form.upper.value=""; form.lower.value=""; form.upper.focus(); form.upper.select(); } </script>
any grateful. tyvy jared moore
hopefully wanted :) new @ answering questions here.
var rand = []; for(var = 1;i<=80;i++){ rand.push(i); } function getrand(){ var index = math.floor(math.random()*rand.length) return rand.splice(index,1) }
Comments
Post a Comment