I am a student of grade 11, I must create a calculator for 4 arithmetic operations in the form:
текст. поле | "radio" -сложение | текст. поле | = текст. поле | "radio" -вычитание| | "radio" -умножение| | "radio" -деление |
Why this program does not work: in the first text. field I enter a number, I enter a number into the second text field, I put the "checked" in addition, I click on the "result", but nothing appears in the third field.
<html> <head> <title>jhgf</title> <body bgcolor=pink> <form name="form1"> <input type=text name=text1 size=5> <input type=r adio name=a rifm1>додавання <input type=text name=text2 size=5>= <input type=text name=text3 size=15> <br> <font color=pink>----------</font> <input type=r adio name=a rifm1>віднімання <br> <font color=pink>----------</font> <input type=r adio name=a rifm1>множення <br> <font color=pink>----------</font> <input type=r adio name=a rifm1>ділення <br> <input type=button value=результат onClick="getRadioValue()"> <!--<br><input type=button value="Вихід" `onClick= f()>--> </form> </body> <script language="javaScript"> function getRadioValue() { var num = document.form1.elements.length; var a = true; for (var i = 0; i < num; i++) { var x = Number(document.form1.text1.value); var y = Number(document.form1.text2.value); if (document.form1.elements[i].type == 'radio'.checked) { document.form1.text3.value = x + y; a = false; break; } } return a; } </script> </head> </html>