selectで選択された数字から条件分岐で数字を”_text”のフォームの中に出力したいです。
javascriptはプロゲートレベルです。よろしくお願いいたします。
function keisan(){ var price5 = document.form1.goods5.options[document.form1.goods5.selectedIndex].value; var price7 = document.form1.goods7.options[document.form1.goods7.selectedIndex].value; if (parseInt(price5) == 0 && parseInt(price7) == 20){ document.write(6370000,form._text.value); }else if(parseInt(price5) == 1 && parseInt(price7) == 20){ document.write(19500000); }else if(parseInt(price5) == 2 && parseInt(price7) == 20){ document.write(22490000); }else if(parseInt(price5) == 3 && parseInt(price7) == 20){ document.write(23400000); }else if(parseInt(price5) == 0 && parseInt(price7) == 30){ document.write(7410000); }else if(parseInt(price5) == 1 && parseInt(price7) == 30){ document.write(20540000); }else if(parseInt(price5) == 2 && parseInt(price7) == 30){ document.write(23530000); }else if(parseInt(price5) == 3 && parseInt(price7) == 30){ document.write(34570000); }else if(parseInt(price5) == 0 && parseInt(price7) == 40){ document.write(8450000); }else if(parseInt(price5) == 1 && parseInt(price7) == 40){ document.write(21190000); }else if(parseInt(price5) == 2 && parseInt(price7) == 40){ document.write(24570000); }else if(parseInt(price5) == 3 && parseInt(price7) == 40){ document.write(25350000); }else if(parseInt(price5) == 0 && parseInt(price7) == 50){ document.write(11700000); }else if(parseInt(price5) == 1 && parseInt(price7) == 50){ document.write(24700000); }else if(parseInt(price5) == 2 && parseInt(price7) == 50){ document.write(27300000); }else if(parseInt(price5) == 3 && parseInt(price7) == 50){ document.write(28600000); }else { document.write("選択してください"); } } ////HTML//// <input type="text" name="_text" size="15" value="0"> <li class="q">①あなたの年齢は? <div class="q1"> <form action="#" name="form1"> <select name="goods7" onChange="keisanif()"> <option value="0">---</option> <option value="20">20代</option> <option value="30">30代</option> <option value="40">40代</option> <option value="50">50代</option> </select> </div> </li> <li class="q">②お子さんの人数は? <div class="q2"> <select name="goods5" onChange="keisans()" onChange="keisanif()"> <option value="00">---</option> <option value="0">0人</option> <option value="1">1人</option> <option value="2">2人</option> <option value="3">3人以上</option> </select> </div> </li> コード
回答1件
あなたの回答
tips
プレビュー