Hey guys i'm stuck on one thing in my javascript code. I have a "clear" button which when pressed erases any text in any of the fields. All that is working fine but i also have the 5 operators which are +, -, x, / and %. I want it so if the user clicks the option for eg "x" and then they hit the clear button it will go back to "+". Heres my code, <html> <head> <title>Web Arithmetic</title> <style type="text/css"> body{ background-color: green; color: gold; font-size: 20px; text-align: center; } </style> <script type="text/javascript"> function validate() { document.frmArithmetic.submit(); } function clean() { document.frmArithmetic.txtNum1.value= ""; document.frmArithmetic.txtNum2.value= ""; document.frmArithmetic.txtNum1.focus(); } </script> </head> <body onload="document.frmArithmetic.txtNum1.focus()"> <h1>Web Arithmetic</h1> <br /><br /><br /><br /><br /> <form name="frmArithmetic" action="jpdset1_1.php"> First number: <input type="text" name="txtNum1" /> <br /><br /><br /><br /> Second number: <input type="text" name="txtNum2" /> <br /><br /><br /><br /> Choose an operator: <br /> <input type="radio" name="optOp" value="+" checked /> + <input type="radio" name="optOp" value="-" /> - <input type="radio" name="optOp" value="x" /> x <input type="radio" name="optOp" value="/" /> / <input type="radio" name="optOp" value="%" /> % <br /><br /><br /> <input type="button" value="Calculate" name="cmdCalculate" onclick="validate()" /> <input type="button" value="Clear" name="cmdClear" onclick="clean()" /> </form> </body> </html> Code (markup): I'm not sure how to do it so if anyone can help me out that would be great. Cheers.
Try: <input type="reset" name="Reset" id="button" value="Reset" /> Code (markup): This button will reset your all input fields and u can call function for focus onclick. <input type="reset" name="Reset" id="button" value="Reset" onClick="document.frmArithmetic.txtNum1.focus()"; /> Code (markup):