JavaScript は初めてです。私が知る限り、他の同様の質問が尋ねられていますが、すべてをまとめる解決策が必要です. どんな助けでも大歓迎です!
{ユーザー数} に {パッケージの価格} を掛けたものに基づいて価格を計算する必要がある次のフォームがあります。
<form id="quote_form">
<fieldset>
<div class="input">
<label>Number of Users:</label> <input type="text" onkeypress="return isNumberKey(event)" name="text" />
</div>
<div class="input">
<label>24/7/365 Support:</label> <input type="checkbox" style="vertical-align:middle;margin:7px 0;" class="bgclear" />
</div>
<div class="input">
<table class="table-2 h7">
<tbody>
<tr>
<td class="color3">Select a package:</td>
<td class="color2">Standard <input id="r1" name="radioCh" value="standard" type="radio" class="bgclear" /></td>
<td class="color2">Standard + <input id="r2" name="radioCh" value="standardPlus" type="radio" class="bgclear" /></td>
<td class="color2">Advanced <input id="r3" name="radioCh" value="advanced" type="radio" class="bgclear" /></td>
</tr>
<tr>
<td>Mail Box</td>
<td>30 GB</td>
<td>30 GB</td>
<td>30 GB</td>
</tr>
<tr>
<td>File Storage</td>
<td>10 GB</td>
<td>10 GB</td>
<td>10 GB</td>
</tr>
<tr>
<td>Microsoft Office</td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
</tr>
<tr>
<td>Microsoft Exchange</td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
</tr>
<tr>
<td>Antivirus</td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
</tr>
<tr>
<td>CRM</td>
<td><img alt="not included" src="images/cross.png"></td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
</tr>
<tr>
<td>Device Independent</td>
<td><img alt="not included" src="images/cross.png"></td>
<td><img alt="included" src="images/tick.png"></td>
<td><img alt="included" src="images/tick.png"></td>
</tr>
<tr>
<td>PBX & VoIP</td>
<td><img alt="not included" src="images/cross.png"></td>
<td><img alt="not included" src="images/cross.png"></td>
<td><img alt="included" src="images/tick.png"></td>
</tr>
</tbody>
</table>
</div>
<div class="input">
<a class="button-3" onclick="getTotal();_gaq.push(['_trackEvent','Quick Quote','Calculate Button','Quote Generated']);">Calculate<img alt="calculate" src="images/buttons/button-3-arrow.png"></a> <div id="finalPrice"></div>
</div>
</fieldset>
</form>
そして、私が値を返すために使用している次の js (私はそれが不完全であり、現在入力ボックスから数値を取得しないことを認識しています (これを行う方法がわかりません!)):
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
function getUserNumber() {
var employeeNum = 0;
var theForm = document.forms["quote_form"];
var numInput = theForm.elements["text"];
}
var monthFee = new Array();
monthFee["standard"]=60;
monthFee["standardPlus"]=80;
monthFee["advanced"]=95;
function getFastQuote() {
var fastQuote = 0;
var theForm = document.forms["quote_form"];
var radioButton = theForm.elements["radioCh"];
for(var i = 0; i < radioButton.length; i++)
{
if(radioButton[i].checked)
{
fastQuote = monthFee[radioButton[i].value];
break;
}
}
return fastQuote;
}
function getTotal() {
var quotePrice = getFastQuote * getUserNumber;
document.getElementById('finalPrice').innerHTML = 'Price from: £' + quotePrice;
}