Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Doctype 'system' and html coding proble.

    hmm. ok here goes (newb to forum).

    i'm coding a volume calculator for my page and there seems to be a problem with my code and my doctype; of which i know liittle about. the calculator ONLY works with doctype='system' and trying to set it to anything BUT system=doesn't work. having doctype=system wreaks havoc with ALL my formating and template (graphics).

    What i'd like to do is find the suspect coding and fix compliant with html5 is possible (Dreamweaver cs5). here you go...

    thanks (very much!) in advance!

    ...j
    Attached Files Attached Files

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    the way you are refering to the form, by just using it's name is only supported by IE.
    By using <!DOCTYPE HTML SYSTEM> you are telling the browser to do in system mode, thus it now handle the document it as the system (and IE) would do it.
    Of course only if the system the page is wiev on is Windows.

    When using other doctypes the page is no longer handled in system mode, thus other browsers than IE don't understand the syntax.

    add this:
    Code:
    <script>
    var fill=document.getElementById('Fill');
    </script>
    And give the form an id="Fill"
    Now other browsers will know what fill is.

    ----
    Another thing is that you are using an awful lot of evals and parenthesis.
    , which almost all can be deleted.

    parenthesis is only needed if you need the calculation to be done in another order than default.
    which is: multiplication and division , is done before substraction and addition

    and eval is only needed in very rare occations

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Lerura View Post
    the way you are refering to the form, by just using it's name is only supported by IE.
    By using <!DOCTYPE HTML SYSTEM> you are telling the browser to do in system mode, thus it now handle the document it as the system (and IE) would do it.
    Of course only if the system the page is wiev on is Windows.

    When using other doctypes the page is no longer handled in system mode, thus other browsers than IE don't understand the syntax.

    add this:
    Code:
    <script>
    var fill=document.getElementById('Fill');
    </script>
    And give the form an id="Fill"
    Now other browsers will know what fill is.

    ----
    Another thing is that you are using an awful lot of evals and parenthesis.
    , which almost all can be deleted.

    parenthesis is only needed if you need the calculation to be done in another order than default.
    which is: multiplication and division , is done before substraction and addition

    and eval is only needed in very rare occations
    Hmmm... well i tried implementing the code suggested and the form id name etc with not much luck I'm afraid. once the changes were made i tried using:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <!DOCTYPE HTML>

    and as i said, neither worked such that the calculator performed calculations and displayed the results. so STILL the only way the calculator works is with <!DOCTYPE system> which also yields very bad graphic layout results.

    any further guidance or help is greatly appreciated!

    ...j

  • #4
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    Please post your current code.
    It should work fine, if done right

  • #5
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    sure...

    here you go! and thanks for all your efforts on my behalf.

    ...j
    Attached Files Attached Files

  • #6
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    Aaah!

    The problem is that you have inserted
    Code:
    <script>
    var fill=document.getElementById('Fill');
    </script>
    BEFORE the form.
    An element can't be refered to, until it is loaded.
    Move it down to the end of the document together with the SpryMenuBar script.

    And in the forms opening tag you have
    Code:
    <form action="" method="get" name="Fill">
    It must be
    Code:
    <form action="" method="get" id="Fill">
    And with the parenthesises and eval I mensioned:
    replace your top <script>with this:
    Code:
    <SCRIPT Language="JavaScript">
    <!-- Hide script from old browser
    
    // clears field of default value
    function clear_field(field) {
                    if (field.value==field.defaultValue) {
                            field.value=''
                    }
            }
    
    // round for money decimal of 2 places
    function calcRound(num) {
    
       result=Math.floor(num)+"." 
       n = result.length
       var cents=100*(num-Math.floor(num))+0.5
       result += Math.floor(cents/10)
       result += Math.floor(cents%10)
       return result} function calsq(form) {
    
             var tonf = 0.010000000000000002; // cubic feet to tons
    
         var rcmunit = fill.rcmunit.value; //cy or tons
         var rwunit = fill.rwunit.value; //ft or in
         var rwidth = fill.rwidth.value; //quantity
         var rwv = rwidth / rwunit; // value now in feet
         var rlunit = fill.rlunit.value; //ft or in
         var rlength = fill.rlength.value; //quantity
         var rlv = rlength / rlunit; // value now in feet
         var rtunit = fill.rtunit.value; //ft or in
         var rthick = fill.rthick.value; //quantity
         var rtv = rthick / rtunit; // value now in feet
         var rcmc = fill.rcmc.value; //money quantity
         var rcir = 0; // factor 1728 cubic inches
         var rcfr = 0; // value in cubic feet
         var rcyr = 0; // factor 27 cubic yards
         var rtonr = 0; // factor tons
         var rcmer = 0; // money
    
             fill.rcfr.value = rwv * rlv * rtv; // value now in cubic feet
             fill.rtonr.value = rwv * rlv * rtv * tonf; // value now in tons
             fill.rcir.value = rwv * rlv * rtv * 1728; // value now in cubic inches
             fill.rcyr.value = (rwv * rlv * rtv) / 27; // value now in cubic yards
            if (rcmunit == 1) {
    
             fill.rcmer.value = calcRound((rcmc * rwv *  rlv * rtv) / 27); // value now in cubic yards
            }
            if (rcmunit == 2) {
    
             fill.rcmer.value = calcRound(rcmc * rwv *  rlv * rtv * tonf); // value now in tons
            }
    
     }
     
    function calrnd(form) {
             var pi = 3.1415929203539825;
             var fton = 0.010000000000000002; // cubic feet to tons
         var cmunit = fill.cmunit.value; //cy or tons
         var depunit = fill.depunit.value; //ft or in
         var depth = fill.depth.value; //quantity
         var depv = depth / depunit; // value now in feet
         var diaunit = fill.diaunit.value; //ft or in
         var diameter = fill.diameter.value; //quantity
         var diav = diameter / diaunit; // value now in feet
         var radius = diameter * .5; // radius
         var radv = radius / diaunit; // value now in feet
         var cmc = fill.cmc.value; //money quantity
         var cir = 0; // factor 1728 cubic inches
         var cfr = 0; // value in cubic feet
         var cyr = 0; // factor 27 cubic yards
         var tonr = 0; // factor tons
         var cmer = 0; // money
             
             fill.cfr.value = radv * radv * depv * pi; // value now in cubic feet
             fill.tonr.value = radv * radv * depv * pi * fton; // value now in tons
             fill.cir.value = radv * radv * depv * pi * 1728; // value now in cubic inches
             fill.cyr.value = (radv * radv * depv * pi) / 27; // value now in cubic yards
            if (cmunit == 1) {
    
             fill.cmer.value = calcRound((cmc * radv * radv * depv * pi) / 27); // value now in cubic yards
            }
            if (cmunit == 2) {
    
             fill.cmer.value = calcRound(cmc * radv * radv * depv * pi * fton); // value now in tons
            }
             
     }
     
    // End hiding here -->
    </SCRIPT>
    As you have it now there are a lot of unnecessary parenthesises.
    And the evals will only slow down your page.

    In your case you are performing the calculations, and thereafter asking the script to evaluate the result.
    - Instead of just calculating it.
    The end result is the same, but with the eval, it have to perform extra unnecessary actions
    Last edited by Lerura; 06-18-2012 at 09:04 PM.

  • Users who have thanked Lerura for this post:

    jmilina (06-18-2012)

  • #7
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ahhh! Thank You!!!

    so simple yet so helpful, thanks again.

    ...j

    Quote Originally Posted by Lerura View Post
    Aaah!

    The problem is that you have inserted
    Code:
    <script>
    var fill=document.getElementById('Fill');
    </script>
    BEFORE the form.
    An element can't be refered to, until it is loaded.
    Move it down to the end of the document together with the SpryMenuBar script.

    And in the forms opening tag you have
    Code:
    <form action="" method="get" name="Fill">
    .
    It must be
    Code:
    <form action="" method="get" id="Fill">


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •