Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required and other questions.... 1

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
US
Hi,

I am trying to convert a vbscript to Javascript. Its been a while since I've done Javascript and for the life of me cannot figure out whats wrong with this code.

Here are the questions....

1. I'm forced to put the startup function in the body section or i get an object required error.

2. Once i put the the startup function there that part works. Then i put in the buildconfig function and of course the object required is back no matter what i do. What am i missing?

Here is the code:

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>4117 Configurator</title>

<script language="Javascript">
Var memCost, driveCost, OSCost, warrantyCost, iTotal, sTotal, wTotal, memDigit, memDesc, driveDigit, driveDesc, OSDigit, OSDesc;
</script>

</head>

<body topmargin="0" leftmargin="0" onLoad="Javascript:setup()">
<form method="POST" action="tbd.html" name="configurator">

<script language="Javascript">
//*********** setup *********************************************
// This sub sets all the variables to thier default values

function setup()
{


window.alert("setup");
document.configurator.catNo.value = "4117T-1400-512-CDW-XP";
document.configurator.mfgNo.value = "4117-0000000002001";
memCost = 0;
driveCost = 0;
OSCost = 0;
warrantyCost = 0;
iTotal = 3995;
sTotal = iTotal + ".00";
document.configurator.lprice.value = sTotal;
memDigit = "0";
memDesc = "-512";
driveDigit = "0";
driveDesc = "-CDW";
OSDigit = "2";
OSDesc = "-XP";
document.configurator.rMem[0].checked = 1;
document.configurator.rDrive[0].checked = 1;
document.configurator.rOS[0].checked = 1;
document.configurator.rWarranty[0].checked = 1;

//Update part number
call buildConfig();
}

//************** end setup *************************************

//***** buildConfig *******************************************************************
//builds the catalog and part number corresponding to what options are selected.
function buildConfig()
{
Var Cat;
Var PN;

window.alert("buildconfig");
Cat = "4117T-1400" + memDesc + driveDesc + OSDesc;
document.configurator.catNo.value = Cat

PN = "4117-000" + memDigit + "00" + driveDigit + "00" + OSDigit + "001";
document.configurator.mfgNo.value = PN;

}
//*************************************************************************************

</script>

the text boxes mfgNo and catNo exists within the form configurator.....
 
Hi

Jouster said:
1. I'm forced to put the startup function in the body section or i get an object required error.
That function refers to some elements of the document. If it runs when those elements are not created yet, it throws an error. The solution is what you figured out.
Jouster said:
2. Once i put the the startup function there that part works. Then i put in the buildconfig function and of course the object required is back no matter what i do. What am i missing?
No [tt]call[/tt] keyword in JavaScript.
Code:
        //Update part number
        [red][s]call[/s][/red] buildConfig();

Feherke.
 
Thanks for the fast reply Feherke.

I can handle putting the startup function in the body, but i still get an error with the buildconfig function even when not using the call keyword. I even commented out the call all together. Just having the buildconfig function in the page causes the object rquired error.... its crazy...

Any other suggestions?

Thanks!
 
Thanks for the suggestion again. I tried that and still have the error.

Here is the full page code:

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>4117 Configurator</title>

<script language="Javascript">
Var memCost, driveCost, OSCost, warrantyCost, iTotal, sTotal, wTotal, memDigit, memDesc, driveDigit, driveDesc, OSDigit, OSDesc;
</script>

</head>

<body topmargin="0" leftmargin="0" onLoad="setup()">
<form method="POST" action="tbd.html" name="configurator">

<script language="Javascript">
//*********** setup *********************************************
// This sub sets all the variables to thier default values

function setup()
{


window.alert(document.configurator.elements[0].name)


window.alert("setup");
document.configurator.catNo.value = "4117T-1400-512-CDW-XP";
document.configurator.mfgNo.value = "4117-0000000002001";
memCost = 0;
driveCost = 0;
OSCost = 0;
warrantyCost = 0;
iTotal = 3995;
sTotal = iTotal + ".00";
document.configurator.lprice.value = sTotal;
memDigit = "0";
memDesc = "-512";
driveDigit = "0";
driveDesc = "-CDW";
OSDigit = "2";
OSDesc = "-XP";
document.configurator.rMem[0].checked = 1;
document.configurator.rDrive[0].checked = 1;
document.configurator.rOS[0].checked = 1;
document.configurator.rWarranty[0].checked = 1;
window.alert(document.configurator.elements[0].value)

//Update part number
buildConfig();
}

//************** end setup ***********************************************************

//***** buildConfig *******************************************************************
//builds the catalog and part number corresponding to what options are selected.
function buildConfig()
{
Var Cat;
Var PN;

window.alert("buildconfig");
Cat = "4117T-1400" + memDesc + driveDesc + OSDesc;
document.configurator.catNo.value = Cat

PN = "4117-000" + memDigit + "00" + driveDigit + "00" + OSDigit + "001";
document.configurator.mfgNo.value = PN;

}
//*************************************************************************************

</script>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="30">
<tr>
<td width="21%" height="30">
<img border="0" src="traveler/labels/Pro-face_blue_without%20R.jpg" width="166" height="30"></td>
<td width="79%" height="30"><b>Create New P.O. : Configure Product</b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="1263" height="13" bgcolor="#1F459F">
<tr>
<td width="1263" height="1" colspan="4" bgcolor="#FFFFFF">
<hr color="#800000" size="3"></td>
</tr>
<tr>
<td width="327" height="30">
<font color="#FFFFFF"><b>&nbsp;</b></font><b><font color="#FFFFFF" size="2">Product Catalog Number:</font><br>
</b>
<input type="text" name="catNo" size="44" readonly><br>
&nbsp;</td>
<td width="256" height="72" rowspan="2">
<p align="right"><b><font color="#FFFFFF" size="2">List Price</font></b><font color="#FFFFFF">: $</font><input type="text" name="lprice" size="20" readonly style="color:#FFFFFF;background-color:#1F459F;border:0px none; "></td>
<td width="200" height="72" rowspan="2">
<img border="1" src="4117_front_angle_lft_.jpg" width="200" height="178"></td>
<td width="480" height="72" rowspan="2">&nbsp;</td>
</tr>
<tr>
<td width="327" height="42">
<b><font color="#FFFFFF">&nbsp;<font size="2">Manufacturing Part Number:</font></font></b><br>
<input type="text" name="mfgNo" size="44" readonly><br>
&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%">
<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="30">
<tr>
<td width="14%" height="30" bgcolor="#FFFFFF" bordercolor="#FFFFFF">
<b>Select Options:</b></td>
<td width="86%" height="30"><hr color="#800000" size="3"></td>
</tr>
<tr>
<td width="170" height="30" bgcolor="#FFFFFF" bordercolor="#FFFFFF" valign="top" nowrap>
<b><font size="2">17\&quot; SXGA (1280x1024) color flat panel display,
touchscreen, Intel® Pentium M 1.4 GHz CPU, 4x AGP Graphics Controller,
up to 2 GB DRAM, 80 GB hard drive, CD-RW w/ DVD-ROM (optional DVD-RW),
three RS-232 serial ports, 2 USB 2.0 Compliant ports, 10/100 and
10/100/1000 Ethernet ports, Audio, AC Power, NEMA 4/4X/12, Windows XP
pre-installed, 1-year warranty.</font></b></td>
<td width="86%" height="30" valign="top">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="110" valign="top" bgcolor="#66CCFF" nowrap>
<p align="right"><b><font size="2">Memory:</font></b></td>
<td width="90%" bgcolor="#CCCCCC"><b>&nbsp;<input type="radio" value="0" name="rMem" checked onClick="Javascript:memConfig(0)"><font size="2">512MB
DRAM - $0.00</font><br>
&nbsp;<input type="radio" name="rMem" value="150" onClick="Javascript:memConfig(1)"><font size="2">1GB DRAM - $150.00</font><br>
&nbsp;<input type="radio" name="rMem" value="400" onClick="Javascript:memConfig(2)"><font size="2">2GB DRAM - $400.00</font></b></td>
</tr>
<tr>
<td width="110" valign="top" bgcolor="#66CCFF" nowrap>
<p align="right"><b><font size="2">Rotating Media Devices:</font> </b></td>
<td width="90%" bgcolor="#CCCCCC"><b>&nbsp;<input type="radio" value="0" name="rDrive" checked onClick="driveConfig(0)"><font size="2">Side
access CD-RW w/ DVD ROM capability - $0.00</font><br>
&nbsp;<input type="radio" name="rDrive" value="300" onClick="driveConfig(1)"><font size="2">Side access DVD-RW
- $300.00</font></b></td>
</tr>
<tr>
<td width="110" valign="top" bgcolor="#66CCFF" nowrap>
<p align="right"><b><font size="2">Operating System:</font> </b></td>
<td width="90%" bgcolor="#CCCCCC"><b>&nbsp;<input type="radio" value="0" name="rOS" checked onClick="OSConfig(0)"><font size="2">Windows
XP - $0.00</font><br>
&nbsp;<input type="radio" name="rOS" value="0" onClick="OSConfig(1)"><font size="2">Windows 2000 -
$0.00</font><br>
&nbsp;<input type="radio" name="rOS" value="-100" onClick="OSConfig(2)"><font size="2">No Operating
System - $-100.00</font></b></td>
</tr>
<tr>
<td width="110" valign="top" bgcolor="#66CCFF" nowrap>
<p align="right"><b><font size="2">Warranty:</font></b></td>
<td width="90%" bgcolor="#CCCCCC"><font size="2"><b>&nbsp;</b></font><b><input type="radio" value="0" checked name="rWarranty" onClick="warrantyConfig(0)"><font size="2">1
Year Standard</font><br>
&nbsp;<input type="radio" name="rWarranty" value="10" onClick="warrantyConfig(1)"><font size="2">1 Year Extended -
10%</font><br>
&nbsp;<input type="radio" name="rWarranty" value="15" onClick="warrantyConfig(2)"><font size="2">2 Year Extended -
15%<br>
&nbsp;</font><input type="radio" name="rWarranty" value="20" onClick="warrantyConfig(3)"><font size="2">3 Year
Extended - 20%<br>
&nbsp;</font><input type="radio" name="rWarranty" value="25" onClick="warrantyConfig(4)"><font size="2">4 Year
Extended - 25%</font></b></td>
</tr>
</table>
<p>
<input type="button" value="Default Values" name="B1" onClick="setup()">&nbsp;
<input type="button" value="Add To Cart" name="B2" onClick="showorder()"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>

Not all of the function have been entered into the page yet. I was trying to get them working one at a time....

Thanks again.
 
Hi

Someone replaced my coffee with decaf ? [banghead] Was all the time there :
Code:
[gray]// lowercase var[/gray]
[red]v[/red]ar memCost, driveCost, OSCost, [gray]...[/gray]

[gray]// lowercase var[/gray]
[red]v[/red]ar Cat;
[red]v[/red]ar PN;

Feherke.
 
WOW! I would have never found it..... I told you its been a while for javascript :).

Thanks alot.... nnow i can get something done.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top