anyone know what are the function for auto choose value... i mean, when i click the button, computer will auto to print/choose the value.... for example... i set the value that computer has to choose is A,B and C... so, when i click the button 'choose' for example, the computer will choose anyone of A, B, C..... (computer/machine will choose randomly)... please help me..... thanks....
This should do it... <html> <head> <script type="text/javascript"> function randomChoose(element) { var randomChoice = (Math.floor((element.length+2-2)*Math.random()) + 3) - 3; element[randomChoice].checked = true; } </script> </head> <body> <form name="theForm"> <input type="radio" name="choice" value="a" /> A<br/> <input type="radio" name="choice" value="b" /> B<br/> <input type="radio" name="choice" value="c" /> C<br/> <input type="radio" name="choice" value="d" /> D<br/> <input type="button" value="Random Choose" onclick="randomChoose(this.form.choice)" /> </form> </body> </html> HTML: You can increase and decrease the number of choices and it should still work.