...

View Full Version : Doctype 'system' and html coding proble.



jmilina
06-17-2012, 01:04 AM
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

Lerura
06-17-2012, 04:56 AM
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:

<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

jmilina
06-18-2012, 07:48 PM
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:

<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
:confused:

Lerura
06-18-2012, 08:08 PM
Please post your current code.
It should work fine, if done right

jmilina
06-18-2012, 08:31 PM
sure...

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

...j

Lerura
06-18-2012, 09:45 PM
Aaah!

The problem is that you have inserted
<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
<form action="" method="get" name="Fill">It must be
<form action="" method="get" id="Fill">

And with the parenthesises and eval I mensioned:
replace your top <script>with this:

<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

jmilina
06-18-2012, 10:05 PM
Ahhh! Thank You!!!

so simple yet so helpful, thanks again.

...j :thumbsup:


Aaah!

The problem is that you have inserted
<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
<form action="" method="get" name="Fill">.
It must be
<form action="" method="get" id="Fill">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum