Jump to content

Script to estimate based on input check boxes


AKmiecik

Recommended Posts

Little help please.  I have a carpet cleaning estimator site at:

http://www.pcsnashville.com/Estimator.php

 

It was working fine until I changed the "value" number (or so I think).

 

Any ideas on why the calculate ain't working would be hugely appreciated.

 

Thanks

 



<!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 content="text/html; charset=us-ascii" http-equiv="Content-Type">
  <meta name="GENERATOR" content="MSHTML 8.00.6001.18852">

  <title></title>
  <script language="javascript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function calculate(f)
{
var nums = f.num;
var ntext = f.numtext;
var nitem = f.Rooms;
var result = 0;
var items = '';
for(var i=0;i<nums.length;i++)
{
if(nums[i].checked)
{
result+=parseFloat(ntext[i].value);
items+=nitem[i].value+'\n';
}
}
f.answer.value=Number(result).toFixed(2);
f.allitems.value=items;
}

function calculate1(f1)
{ 
var nums1 = f1.num1;
var ntext1 = f1.numtext1;
var nitem1 = f1.Protect;
var test = 0;
var pitems = '';
for(var j=0;j<nums1.length;j++)
{
if(nums1[j].checked)
{
test+=parseFloat(ntext1[j].value);
pitems+=nitem1[j].value+'\n';
}
}
f1.answer1.value=Number(test).toFixed(2);
f1.allitems1.value=pitems;
}
function area(form) {
a=eval(form.answer.value)
b=eval(form.answer1.value)
s=eval(form.steps.value)
{
if(b==undefined)
{
form.silver.value = a+s*5
form.gold.value = a*(45/35)+s*5
form.platinum.value = a*(55/35)+s*5
}
else
{

form.silver.value = a+b+s*5
form.gold.value = a*(45/35)+b+s*5
form.platinum.value = a*(55/35)+b+s*5

}
}
}
</script>
</head>

<body>
  <form name="form1" action="thankyou.php" method="post" onsubmit="return check();">
    <table class="table1" width="500" border="1" bgcolor="#ffffff">
      <tr class="blue"  bgcolor="#000000"><!-- Row 1 -->

        <td width="291" colspan="2">
          <p style="PADDING-RIGHT: 5px" align="right"><strong><em><font color="#ffffff">Pick rooms<br>
          to be cleaned</font></em></strong></p>
        </td><!-- Col 1 --><!-- Col 2 -->

        <td width="118">
          <p align="center"><font color="#ffffff" size="2">Add<br>
          Genuine 3M Protectant</font></p>
        </td><!-- Col 3 -->
      </tr>

      <tr>
        <td width="622">
          <p align="right"><font size="2">Family Room:</font></p>
        </td>

        <td width="263">
          <p align="center"><font size="2">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Family Room" onchange="calculate(this.form)"></font></p>
        </td>

        <td width="118">
          <p align="center"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Family Room" onchange="calculate1(this.form)"></font></p>
        </td>
      </tr>

      <tr><!-- Row 2 -->

        <td width="622">
          <p align="right"><font size="2">  Living Room:</font></p>
        </td><!-- Col 1 --><!-- Col 2 -->

        <td width="263">
          <p align="center"><font size="2">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Livng Room" onchange="calculate(this.form)"></font></p>
        </td>

        <td width="118">
          <p align="center"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1" input=""> 		   	
	  <input type="hidden" name="Protect" value="Living Room" onchange="calculate1(this.form)"></font></p>
        </td><!-- Col 3 -->
      </tr>

      <tr><!-- Row 2a -->

        <td width="622"><!-- Row 2a  Col 1 -->

          <p align="right"><font size="2"> Dining Room:</font></p>
        </td><!-- Row 2a  Col 1 -->

        <td width="263">
          <p align="center"><font size="2">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Dining Room" onchange="calculate(this.form)"></font></p>
        </td>

        <td width="118">
          <p align="center"><font size="2"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Dining Room" onchange="calculate1(this.form)"></font></font></p>
        </td><!-- Row 2a  Col 2 -->
      </tr><!-- Row 2a -->

      <tr><!-- Row 3 -->

        <td width="622">
          <p align="right"><font size="2"> Master Bedroom(s):</font></p>
        </td><!-- Col 1 --><!-- Col 2 -->

        <td width="263">
          <p align="center">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Master Bed 1" onchange="calculate(this.form)"> 
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Master Bed 2" onchange="calculate(this.form)"></p>
        </td>

        <td width="118">
          <p align="center"><font size="2"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Master Bed 1" onchange="calculate1(this.form)"> <font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Master Bed 2" onchange="calculate1(this.form)"></font></font></font></p>
        </td><!-- Col 3 -->
      </tr>

      <tr><!-- Row 4 -->

        <td width="622">
          <p align="right"><font size="2">  Bedroom(s):</font></p>
        </td><!-- Col 1 --><!-- Col 2 -->

        <td width="263">
          <p align="center"><font size="2">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="1" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Bedroom 1" onchange="calculate(this.form)"> 
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Bedroom 2" onchange="calculate(this.form)"><br>
          <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="1" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Bedroom 3" onchange="calculate(this.form)"> 
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Bedroom 4" onchange="calculate(this.form)"></font></p>
        </td>

        <td width="118">
          <p align="center"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Bedroom 1" onchange="calculate1(this.form)"> <font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Bedroom 2" onchange="calculate1(this.form)"><br>
          <font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Bedroom 3" onchange="calculate1(this.form)"> <font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Bedroom 4" onchange="calculate1(this.form)"></font></font></font></font></p>
        </td><!-- Col 3 -->
      </tr>

      <tr><!-- Row 5 -->

        <td width="622">
          <p align="right"><font size="2">  Hallway:</font></p>
        </td><!-- Col 1 --><!-- Col 2 -->

        <td align="middle" width="263">
          <p align="center"><font size="2">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Hallway" onchange="calculate(this.form)"></font></p>
        </td>

        <td align="middle" width="118">
          <p align="center"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Hallway" onchange="calculate1(this.form)"></font></p>
        </td><!-- Col 3 -->
      </tr>

      <tr>
        <td width="622">
          <p align="right"><font size="2">Bonus Room(s):</font></p>
        </td>

        <td width="263">
          <p align="center">
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Bonus Room 1" onchange="calculate(this.form)"> 
	  <input onclick="calculate(this.form)" type="checkbox" name="num"> 
	  <input type="hidden" onchange="calculate(this.form)" size="2" value="35" name="numtext"> 
	  <input type="hidden" name="Rooms" value="Bonus Room 2" onchange="calculate(this.form)"></p>
        </td>

        <td width="118">
          <p align="center"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Bonus Room 1" onchange="calculate1(this.form)"> 
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="15" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Bonus Room 2" onchange="calculate1(this.form)"></font></p>
        </td>
      </tr>

      <tr>
        <td width="622">
          <p align="right"><font size="2">Number of Stair Steps:</font></p>
        </td>

        <td width="263">
          <p align="center"><font size="2">
	  <input style="WIDTH: 26px; HEIGHT: 22px" type="number" align="center" size="1" value="0" name="steps"></font></p>
        </td>

        <td>
          <p align="center"><font size="2">
	  <input onclick="calculate1(this.form)" type="checkbox" name="num1"> 
	  <input type="hidden" onchange="calculate1(this.form)" size="1" value="0" name="numtext1"> 
	  <input type="hidden" name="Protect" value="Stairs" onchange="calculate1(this.form)"></font></p>
        </td>
      </tr>

      <tr><!-- Row 7 -->

        <td width="622" top="">
          <p align="right"> </p>
        </td><!-- Col 1 -->

        <td width="263">
          <p align="center"><font size="2">
	  <input style="WIDTH: 66px; HEIGHT: 24px" onclick="area(this.form)" type="button" size="6" value="Calculate"></font></p>
        </td>

        <td>
          <p align="center">
	  <input type="reset" value="Reset" name="" object=""></p>
        </td>
      </tr>
    </table><!-- End Table 1 -->

    <table class="table2" cellpadding="5">
      <tr height="29">
        <td colspan="2">
          <p align="center"><font size="2">Mouse over product name to see description</font></p>
        </td>
      </tr>

      <tr>
        <td colspan="2">
          <p align="center"><A class=pop href="#"><font color="#000040" size="3">
	  Sterling <span style="TEXT-DECORATION: none"><?php include("Sterling.php"); ?></span></font></a> :
	  <strong><em><font color="#800000">"We Work Together"</font></em></strong> <br>
          You pre-vacuum and move furniture, we do the rest.<br>$
          <input size="5" name="silver" style="HEIGHT: 22px" maxlength="4" number="silver"> </p>
        </td>
      </tr>

      <tr>
        <td colspan="2">
          <p align="center"><A class=pop2 href="#"><u><font color="#000040" size="3">Gold <span style="TEXT-DECORATION: none"><?php include("Gold.php"); ?></span></font></u></a> : <strong><em><font color="#800000">"We Do Most of the Work"</font></em></strong><br>
          You pre-vacuum, we do the rest.<br>
          $<input size="5" name="gold" style="WIDTH: 65px; HEIGHT: 22px" maxlength="4" number="gold"> </p>
        </td>
      </tr>

      <tr height="2">
        <td colspan="2">
          <p align="center"><A class=pop3 href="#"><u><font color="#000040" size="3">Platinum 
	  <span style="TEXT-DECORATION: none"><?php include("Platinum.php"); ?></span></font></u></a> :  <strong><em><font color="#800000">"We Do It All"</font></em></strong><br>
          ...<strong><em>and come back in six months and do it again.<br></em></strong>$<input style="HEIGHT: 22px" size="5" name="platinum" maxlength="4" number="platinum"></p>
        </td>
      </tr>

      <tr>
        <td></td>
      </tr>
    </table><!-- end table 2 -->
  </form>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.