Click to See Complete Forum and Search --> : Error: Object does not support this property or method


janvanheerden
12-23-2002, 03:00 AM
Hi everybody,

I have a form with 3 textboxes:

DegrNo Where I ask the client to enter a number
DegrUnit This is a readonly box with the value a number
DegrTot This is also a readonly box

I want to multiply the value of DegrNo with the value of DegrUnit and store the result in DegrTot

The code is as below:

<script language = "JavaScript" type = "text/JavaScript">
<!-- // Hide this script from non-script browsers

var DegrNo = parseInt("document.Form1.DegrNo.value" ,10);
var DegrUnit = parseInt("document.Form1.DegrUnit.value" ,10);
var DegrTot;
function DegrTot (DegrNo,DegrUnit){ // Calculate total cost for degrees
DegrTot = DegrNo * DegrUnit;
document.Form1.DegrTot.value=DegrTot;
}
//--> // End of hide script
</script>

I call the function from the DegrNo textbox as follows:


<input type="text" name="DegrNo" size="6" value="0" onChange="DegrTot() " >

I get a runtime error: Object does not support this property or method.

What am I doing wrong? Your help will be appreciated.

Thanks,

Jan

ShrineDesigns
12-23-2002, 03:49 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/JavaScript">
<!--
function multiply(){
var Dno = document.form1.DegrNo.value;
var Dunit = document.form1.DegrUnit.value;
var multi = Dunit * Dno;
var Dtot = document.form1.DegrTot.value;
if (Dno > 0){
document.form1.DegrTot.value = multi;
}
}
//-->
</script>
</head>
<body>
<form action="" method="" name="form1">
<input name="DegrNo" type="text" onBlur="multiply()">
<input name="DegrUnit" type="text" value="5">
<input name="DegrTot" type="text">
</form>
</body>
</html>

Charles
12-23-2002, 04:44 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">Should be:

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

or better yet:

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

And you always need to specify a character set:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

or better yet:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

aepstar
12-23-2002, 04:54 AM
as our friend charles said this is line is better in his humble opinion: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/strict.dtd">
however did u know if u use that line and let the parser validate ur page it will generate fault report if:

- u can't use frames
- u cant use link targets
- u cant use any of the following tags: BASEFONT, CENTER, FONT, S, STRIKE, U, APPLET, DIR, ISINDEX and MENU.

so i would rahter choose for this line:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

or just <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

peace man

Charles
12-23-2002, 06:04 AM
Use just

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

and you cannot use the mnemonic enetites. Use

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

and the depricated elements and attributes and your page will work on fewer browsers. HTML 4.01 Strict was created, and those troublesome attributes and elements were eliminated, for some very good reasons. And the transitional DTD doesn't support frames. For that use

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

And aepstar may find http://www.grammarbook.com/ to be of some use.

aepstar
12-23-2002, 06:52 AM
charles i had an a+ for my grammar, so allow me to write now how i want! coz i am so tired of writing correctly.

janvanheerden
12-23-2002, 08:47 AM
Hi everybody,

Thank you for your replies.

I will study it carefully and I am sure it will work.

Jan