javascript - ''x'' is not a function -


the function should return "this true" doesn't appear working. telling me

randomquestion not defined.

what doing wrong?

//questions function randomquestion() {   var quest = "this true";   var string_length = 1;   var randomstring = "";    (var i=0; i<string_length; i++)    {     var rnum = math.floor(math.random() * quest.length);     randomquestion += quest.substring(rnum,rnum+1);   }    document.questions.questfield.value = randomquestion; }  <!--questions form--> <form name="questions"> <input type="button" value="question" onclick="randomquestion();">&nbsp; <input type="text" name="questfield" value=""> </form> 

the name of function randomquestion, in function, write:

randomquestion += ... 

i noticed didn't use variable randomstring in function. maybe want use randomstring += instead of using randomquestion += ...?

here code edited:

<html>     <body>         <script>             function randomquestion() {                 var quest = "this true";                 var string_length = 1;                 var randomstring = "";                 var = 0;                 var rnum = 0;                 (i = 0; < string_length; i++) {                     rnum = math.floor(math.random() * quest.length);                     randomstring += quest.substring(rnum, rnum + 1);                 }                 document.questions.questfield.value = randomstring;             }         </script>         <form name="questions">             <input type="button" value="question" onclick="randomquestion();">             <input type="text" name="questfield" value="">         </form>     </body> </html> 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -