Web Analytics Made Easy -
StatCounter Help with Code in "Estimator" - CodingForum

Announcement

Collapse
No announcement yet.

Help with Code in "Estimator"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Code in "Estimator"

    Hi everyone i have this online estimator i am trying desperately to get to here is code:

    funct<script language="javaScript">
    <!--
    function conv_number(expr, decplaces)
    { // var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
    while (str.length <= decplaces) {
    str = "0" + str;
    }
    var decpoint = str.length - decplaces;
    return (str.substring(0,decpoint) + "." + str.substring(decpoint,str.length));
    }
    function room(Form) {




    a1 = document.FrontPage_Form1.length1.value; <------------------This is the line it is referreing to..if i eliminate itgoes to next line as being null an void
    b1 = document.FrontPage_Form1.width1.value;
    aa1= document.FrontPage_Form1.Servicetype1.value;
    f1 = 0;
    a2 =document.FrontPage_Form1.length2.value;
    b2 = document.FrontPage_Form1.width2.value;
    aa2=document.FrontPage_Form1.Servicetype2.value;
    f2 = 0;
    a3 = document.FrontPage_Form1.length3.value;
    b3 = document.FrontPage_Form1.width3.value;
    aa3=document.FrontPage_Form1.Servicetype3.value;
    f3 = 0;
    a4 = document.FrontPage_Form1.length4.value;
    b4 = document.FrontPage_Form1.width4.value;
    aa4=document.FrontPage_Form1.Servicetype4.value;
    f4 = 0;
    a5 = document.FrontPage_Form1.length5.value;
    b5 = document.FrontPage_Form1.width5.value;
    aa5=document.FrontPage_Form1.Servicetype5.value;
    f5 = 0;
    a6 = document.FrontPage_Form1.length6.value;
    b6 = document.FrontPage_Form1.width6.value;
    aa6=document.FrontPage_Form1.Servicetype6.value;
    f6 = 0;
    a7 = document.FrontPage_Form1.length7.value;
    b7 = document.FrontPage_Form1.width7.value;
    aa7=document.FrontPage_Form1.Servicetype7.value;
    f7 = 0;
    bb8 = document.FrontPage_Form1.upholstery1.value;
    a8 = document.FrontPage_Form1.pieces8.value;
    f8 = 0;
    bb9 = document.FrontPage_Form1.upholstery2.value;
    a9 = document.FrontPage_Form1.pieces9.value;
    a10 = document.FrontPage_Form1.stairst10.value;
    f9 = 0;
    f10 = 0;

    if (isNaN(a1)) {
    alert("OOPS! " + document.FrontPage_Form1.length1.value + " is not a number ");
    }
    else {
    c1 = a1*b1;
    }
    if (isNaN(b1)) {
    alert("OOPS! " + document.FrontPage_Form1.width1.value + " is not a number ");
    }
    else {
    c1 = a1*b1;
    }





    e1= a1 * b1
    document.FrontPage_Form1.sqft1.value = Math.round(e1);
    f1 = e1* aa1;
    document.FrontPage_Form1.total1.value = conv_number(f1,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    c2 = a2*b2
    d2 = c2*(.0)
    e2 = c2 + d2
    document.FrontPage_Form1.sqft2.value = Math.round(e2);
    f2 = e2 * aa2;
    document.FrontPage_Form1.total2.value = conv_number(f2,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    c3 = a3*b3;
    d3 = c3*(.0)
    e3 = c3 + d3
    document.FrontPage_Form1.sqft3.value = Math.round(e3);
    f3 = e3* aa3;
    document.FrontPage_Form1.total3.value = conv_number(f3,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    c4 = a4*b4;
    d4 = c4*(.0)
    e4 = c4 + d4
    document.FrontPage_Form1.sqft4.value = Math.round(e4);
    f4 = e4* aa4;
    document.FrontPage_Form1.total4.value = conv_number(f4,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    c5 = a5*b5;
    d5 = c5*(.0)
    e5 = c5 + d5
    document.FrontPage_Form1.sqft5.value = Math.round(e5);
    f5 = e5* aa5;
    document.FrontPage_Form1.total5.value = conv_number(f5,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    c6 = a6*b6;
    d6 = c6*(.0)
    e6 = c6 + d6
    document.FrontPage_Form1.sqft6.value = Math.round(e6);
    f6 = e6* aa6;
    document.FrontPage_Form1.total6.value = conv_number(f6,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    c7 = a7*b7;
    d7 = c7*(.0)
    e7 = c7 + d7;
    document.FrontPage_Form1.sqft7.value = Math.round(e7);
    f7 = e7* aa7;
    document.FrontPage_Form1.total7.value = conv_number(f7,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);




    f8 = bb8 * a8;
    document.FrontPage_Form1.total8.value = conv_number(f8,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);


    f9 = bb9* a9;
    document.FrontPage_Form1.total9.value = conv_number(f9,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10;
    document.FrontPage_Form1.total.value = conv_number(g,2);



    f10 = a10*3.18;
    document.FrontPage_Form1.total10.value = conv_number(f10,2);
    g = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 ;
    document.FrontPage_Form1.total.value = conv_number(g,2);
    }
    //-->
    </script>
    I keep getting message: "document frontpage form1.length1 is not an object or is null"
    I have tweeked this maybe too much

    any help appreciated

  • #2
    Well, you don't show us the <FORM> so we can't tell. Maybe it really isn't an object.

    If possible, show the page ONLINE someplace. If not, show the HTML of the <FORM>.
    Be yourself. No one else is as qualified.

    Comment


    • #3
      funct<script language="javaScript">
      <!--
      function conv_number(expr, decplaces)
      { // var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
      while (str.length <= decplaces) {
      str = "0" + str;
      }
      var decpoint = str.length - decplaces;
      return (str.substring(0,decpoint) + "." + str.substring(decpoint,str.length));
      }


      This function to return x decimal places is utterly obsolete.
      Simply use str.toFixed(2) instead.

      There are other flaws in your code. For example, what is d5 = c5*(.0) supposed to do?
      The endless repetion of document.FrontPage_Form1 suggests that the code could be greatly simplified.

      <script language="javaScript"> is also deprecated and obsolete. Use <script type = "text/javascript"> instead.

      BTW, please follow the posting guidelines and wrap your code in [code] tags. This means use the octothorpe or # button on the toolbar. The word CODE should be in capitals and within square brackets, but of course if I do that here it will wrap code tags around this text. You can edit your previous post.



      "When the questions are being asked, that's when you come up with the answers." - Sports commentator
      Last edited by Philip M; Apr 9, 2009, 02:42 AM.

      All the code given in this post has been tested and is intended to address the question asked.
      Unless stated otherwise it is not just a demonstration.

      Comment

      Working...
      X