אני צריך להגיש מחשבון שפועל בHTML ובJS אבל אני לא מצליח הנה הקוד:
מישהו יכול לעזור לי למצוא את הבעיה?קוד HTML:<html> <body> <p style="font-family:Arial; text-align:center; font-size:36px;">Calculator</p> <p style="font-family:Arial; text-align:center; font-size:20px;"> You need to put 2 numbers and a computational operation and to press "Solve!" and the computer will solve it </p> <form><center><p> <input type="text" id="number1" size="4" value="num1"> <input type="text" id="CC" size="1" value="* / + -"> <input type="text" id="number2" size="4" value="num2"> = <input type="text" id="answer" size="20" value="answer"> <br> <input type="button" value="Solve!" onclick="calc()"> <p id="d"></p> </p> </center> </body> <script> function calc() { var num1 = document.getElementById('number1').value var num2 = document.getElementById('number2').value var cc = document.getElementById('CC').value var sol = "0" if ( cc != "*" || cc != "+" || cc != "/" || cc != "-") { sol = "Please put a computational operation." } else { if (cc == "*"){ sol = num1*num2 } if (cc == "-"){ sol = num1-num2 } if (cc == "+"){ sol = num1+num2 } if (cc== "/" ){ if (num2 == "0"){ sol = "You can't divide any thing with 0" } else { sol = num1/num2 } } } document.getElementById('answer').value = sol } } </script> </html>





