最近javascriptをやり始めました。上記のようなエラーが出てしまい、動作しません。原因が分からないので、教えていただきたいです。
<!-- function keisan(){ // 祈願者1 var price1 = document.yaku_form.k1price.options[document.yaku_form.k1price.selectedIndex].value; // 祈願者2 var price2 = document.yaku_form.k2price.options[document.yaku_form.k2price.selectedIndex].value; // 祈願者3 var price3 = document.yaku_form.k3price.options[document.yaku_form.k3price.selectedIndex].value; // 合計を計算 var total = parseInt(price1) + parseInt(price2) + parseInt(price3); // 設定終了 document.yaku_form.field_total.value = total; // 合計を表示 } // --> </script> </head> <body><center> <div><h1>ご祈願申し込み</h1></div onsubmit="return validate()"> <div><form action="form2.php" method="post" name="yaku_form"> <p><strong><label for="k1-3">・祈願料</label></strong></p> <select style="width: 220px; height: 30px; font-size:20px; font-weight:bold; size="30"" name="k1price" onChange="keisan()"> <option value="0" selected>未選択</option> <option value="1000">金紙札 1000円</option> <option value="3000">木札 小 3000円</option> <option value="5000">木札 中 5000円</option> <option value="7000">木札 大 7000円</option> </select> <p><strong><label for="k2-3">・祈願料</label></strong></p> <select style="width: 220px; height: 30px; font-size:20px; font-weight:bold; size="30"" name="k2price" onChange="keisan()"> <option value="0" selected>未選択</option> <option value="1000">金紙札 1000円</option> <option value="3000">木札 小 3000円</option> <option value="5000">木札 中 5000円</option> <option value="7000">木札 大 7000円</option> </select> <p><strong><label for="k3-3">・祈願料</label></strong></p> <select style="width: 220px; height: 30px; font-size:20px; font-weight:bold; size="30"" name="k2price" onChange="keisan()"> <option value="0" selected>未選択</option> <option value="1000">金紙札 1000円</option> <option value="3000">木札 小 3000円</option> <option value="5000">木札 中 5000円</option> <option value="7000">木札 大 7000円</option> </select> <p><strong>合計金額:</strong><input type="text" name="field_total" value="0"> 円</p> </form></div> </center> </body>

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。