Hey, i have a Mortage Loan Calculator and currently it is making calculations only in Annuity long term loan but it should also have an option to select One-time repayment of short-term loan. I have all the calculating codes but i can't seem to find a way how to make the radio group i have, to select which type of calculator it uses. Is there some kind of IF statement like, if that is selected do that else, something else. I am pretty noob in javascript so if anyone could help me, that would be awesome.
The Javascript code
Code:
function check() { 
	var loanamt = top.document.loan_form.amt.value;
	var paymnt = top.document.loan_form.pay.value;
	var rate = top.document.loan_form.rate.value;

	if(loanamt=="" || isNaN(parseFloat(loanamt)) || loanamt==0) { 
		alert("Please enter a valid loan amount.");
		top.document.loan_form.amt.value="";
		top.document.loan_form.amt.focus();
		return false; 
	} else if(paymnt=="" || isNaN(parseFloat(paymnt)) || paymnt==0) {
		alert("Please enter a valid number of payments.");
		top.document.loan_form.pay.value="";
		top.document.loan_form.pay.focus();
		return false; 
	} else if(rate=="" || isNaN(parseFloat(rate)) || rate==0) {
		alert("Please enter the interest rate.");
		top.document.loan_form.rate.value="";
		top.document.loan_form.rate.focus();
		return false; 
	} else {
		show(); 
	}
}

function clearScreen() { 
	top.document.loan_form.amt.value="";
	top.document.loan_form.pay.value="";
	top.document.loan_form.rate.value="";
	top.document.getElementById("pmt").innerHTML="";
	top.document.getElementById("det").innerHTML="";
}

function fixVal(value,numberOfCharacters,numberOfDecimals,padCharacter) { 
	var i, stringObject, stringLength, numberToPad;            // define local variables

	value=value*Math.pow(10,numberOfDecimals);                 // shift decimal point numberOfDecimals places
	value=Math.round(value);                                   //  to the right and round to nearest integer

	stringObject=new String(value);                            // convert numeric value to a String object
	stringLength=stringObject.length;                          // get length of string
	while(stringLength<numberOfDecimals) {                     // pad with leading zeroes if necessary
		stringObject="0"+stringObject;                     // add a leading zero
		stringLength=stringLength+1;                       //  and increment stringLength variable
	}

	if(numberOfDecimals>0) {			           // now insert a decimal point
		stringObject=stringObject.substring(0,stringLength-numberOfDecimals)+"."+
		stringObject.substring(stringLength-numberOfDecimals,stringLength);
	}

	if (stringObject.length<numberOfCharacters && numberOfCharacters>0) {
		numberToPad=numberOfCharacters-stringObject.length;      // number of leading characters to pad
		for (i=0; i<numberToPad; i=i+1) {
			stringObject=padCharacter+stringObject;
		}
	}

	return stringObject;                                       // return the string object
}

function show() {
	var amount=parseFloat(top.document.loan_form.amt.value);
	var numpay=parseInt(top.document.loan_form.pay.value);
	var rate=parseFloat(top.document.loan_form.rate.value);
 
	rate=rate/100;
	var monthly=rate/12;
	var payment=((amount*monthly)/(1-Math.pow((1+monthly),-numpay)));
	var total=payment*numpay;
	var interest=total-amount;

	var output = "";
	var detail = "";

	output += "<table align='center' style='width:90%;margin:10px'> \
			<tr><td>Total payment:</td><td align='right'>"+fixVal(total,0,2,' ')+"</td></tr> \
			<tr><td>Total intrests:</td><td align='right'>"+fixVal(interest,0,2,' ')+"</td></tr></table>";

	detail += "<table border='0' align='center' cellpadding='5' cellspacing='0' width='97%'> \
			<tr><td align='center' valign='bottom'><b>Kuu</b></td><td align='right' valign='bottom'><b>Amount</b></td> \
			<td align='right' valign='bottom'><b>Intress</b></td><td align='right' valign='bottom'><b>Main amount</b></td> \
			<td align='right' valign='bottom'><b>Whats left</b></td></tr><tr><td align='center' >0</td> \
			<td align='center'>&nbsp;</td><td align='center'>&nbsp;</td><td align='center'>&nbsp;</td> \
			<td align='right'>"+fixVal(amount,0,2,' ')+"</td></tr>";

	newPrincipal=amount;

	var i = 1;
	while (i <= numpay) {
		newInterest=monthly*newPrincipal;
		reduction=payment-newInterest;
		newPrincipal=newPrincipal-reduction;
		
		detail += "<tr><td align='center'>"+i+"</td><td align='right'>"+fixVal(payment,0,2,' ')+"</td> \
				<td align='right'>"+fixVal(newInterest,0,2,' ')+"</td> \
				<td align='right'>"+fixVal(reduction,0,2,' ')+"</td> \
				<td align='right'>"+fixVal(newPrincipal,0,2,' ')+"</td></tr>";

		i++;
	}

	detail += "</table>";

	document.getElementById("pmt").innerHTML = output;
	document.getElementById("det").innerHTML = detail;
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
The HTML code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Annuiteet</title>

<style type="text/css">
<!--
.loan {
}

.loan div {
	border: 1px solid #999;
	margin: 1px;
}

.loan .loan_src {
	float: left;
	height: 190px;
	width: 259px;
	border:0;
}

.loan .loan_pmt {
	float: left;
	width: 317px;
	height: 190px;
	border:0;
}

.loan .loan_out {
	clear: both;
	overflow: auto;
	max-height: 770px;
	width:50%;
	border:0;
}#title a {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 90%;
	height: 20px;
	font-weight: bold;
	width: 476px;
	text-align: left;
	margin: auto;
	text-decoration: none;
	float: right;
	color: #000066;
	background-color: #E3EFF5;
}

.style2 {
	font-size: 100%;
	font-weight: bold;
}
-->
</style>
<script type="text/javascript" src="http://omalaen.ee/calc.js"></script>
</head>

<body bgcolor="#e8f0f6">

<div id="calc_script">
  
  
  
  
  
  
  <div class="loan">

			<div class="loan_src" id="srcamt">

				<form name="loan_form">

				<table align='center' style="margin:10px">

				<tr>



					<td width="145"><span style="font-size:100%">Amount (&euro;):</span></td>

					<td width="88"><input type="text" name="amt" size="10" /></td>

				</tr>

				<tr>

					<td><span style="font-size:100%">Time (months):</span></td>

					<td><input type="text" name="pay" size="10" /></td>

				</tr>

				<tr>



					<td> <span style="font-size:100%">Intrests (%)</span></td>

					<td><input type="text" name="rate" size="10" /></td>

				</tr>
                <tr>

					<td colspan='2' align='center' style='padding-top:5px'>
                      <p>
                      <label>
                          <input name="calc_type" type="radio" value="1" id="calc_type_1" checked="checked" />
                          Annuity long time</label>
                        <br />
                        <label>
                          <input type="radio" name="calc_type" value="2" id="calc_type_2" />
                         One time payment</label>
                        <br />
                        
                    </p></td>
				<tr>

					<td colspan='2' align='center' style='padding-top:5px'>

						<input type="button" class="button" onClick="return check()" value="Calculate" />&nbsp;&nbsp;&nbsp;


					</td>



				</tr>

				</table>

				</form>

			</div>

			<div class="loan_pmt" id="pmt"></div>

			<div class="loan_out" id="det"></div>

			

		</div>

    
  


 
 
 
 
 
      </div>
</body>
</html>