patk570 42 Newbie Poster

Hello everyone. I seem to be having trouble with the doMath() section of my code. I was wondering if you can help me out...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Package Plans</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<SCRIPT LANGUAGE="JavaScript">
function  doMath() {
var one = eval(document.theForm.elements[0].value);
var two = eval(document.theForm.elements[1].value);
var outp = "";
var outps = "";
	{
    ans = one*two;
    ansq = (one*two)*12;
    outp = " " + "$" + ans.toFixed(2) + "/Month";
    outps = " " + "$" + ansq.toFixed(2) + "/Year";

}
  document.getElementById('outtab').innerHTML = outp;
document.getElementById('outtab1').innerHTML = outps;
} 
</SCRIPT>
<script type="text/javascript">
function calcPackage(){
var text = document.getElementById('price');
var rad=document.one.gb;
for(var i=0;i<rad.length;i++){
	if(rad[i].checked){
		switch(rad[i].value){
		case '5':text.value = '2.50';break;
		case '10':text.value = '2.00';break;
		case '15':text.value = '2.00';break;
		case '20':text.value = '1.75';break;
		case '30':text.value = '1.25';break;
		case '50':text.value = '0.80';break;
		case '100':text.value = '0.50';break;
		default: text='';break;
		}
	}
}
document.getElementById('price').innerHTML = text;
}
</script>
</head>
<body>
<form name="one" onClick="calcPackage()">
		<fieldset>
	 		<p><strong>Choose a type of fruit, then click the button below:</strong><br/>				 
	 		<input type="radio" name="gb" value="5">I just use my computer for email and surfing the web.  I have a few documents and other files I need to back up.<br/>
	 		<input type="radio" name="gb" value="10">
	 		I have some music and a few files, I am in school/college and need to backup my work.<br/>
	 		<input type="radio" name="gb" value="15">
	 		I have 50 songs, pictures, and documents, I do not want to lose.
	 		<br/>
	 		<input type="radio" name="gb" value="20">
	 		I have a lot of documents that need to be backed up regulary, plus some music.<br/>
	 		<input type="radio" name="gb" value="30">
	 		I own small business and need to backup a few computers.<br/>
	 		<input type="radio" name="gb" value="50">
	 		I have a few 100 songs, and need to protect them!<br/>
	 		<input type="radio" name="gb" value="100">I'm a music and picture hound.  My life's collection of MP3s and every picture I've ever taken is on my computer.<br/>
			</p>
 		</fieldset>	
		  
  <p>
  </p>
  <div>$<input name="two" type="text" DISABLED id="price" size="8"></div>
<input type="button" onclick="doMath()" value="Calculate Total" >
<input type="reset" value="Reset Form" />
<BR><BR>Monthly Total:<SPAN ID="outtab"></SPAN>
<br>Yearly Total:<SPAN ID="outtab1"></SPAN>
</form>
<br><BR>
</body>
</html>

Thanks everyone...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.