Need help with some basic HTML / JAVA coding?

I'm suppose to make a program with HTML/JAVA that allows the computer to determine if the number inputted in textbox 1 is odd or even. The computer will compute this once the button is pushed. It will present the result, odd or even, in the 2nd text box. <html> <head> <title>If it's Odd or Even</title> </head> <body> <form name = "myForm"> <!Output Instructional text> Enter Any #: <!Output textboxes and button to compute if inputted # is odd or even> <input type = "textbox" name = "textbox1"> <script language = "Javascript"> document.myForm.textbox1.value = ' '; var a = document.myForm.textbox1.value; var b; </script> <input type = "button" value = "Calculate Odd or Even" onClick = "a = document.myForm.textbox1.value; a = eval(a); b = a % 2; if (b == 0) a = even; { document.myForm.textbox2.value = a; } if (b == 1) a = odd; { document.myForm.textbox2.value = a; }" > <br> <br> Result: <input type = "textbox" name = "textbox2"> </form> </body> </html>

Public Comments

  1. Easiest way possible: <html> <head> <title>If it's Odd or Even</title> </head> <body> <form> <input id="a"> <input type="button" value="Calculate Odd or Even" onclick="b.value = a.value % 2 == 0 ? 'even' : 'odd';"><br> <input id="b"> </form> </body> </html> Also, this is called Javascript, not Java.
Powered by Yahoo! Answers