I have seen this code used throughout the internet. I need help because I edited the code not knowing anything about java. I was able to get my first list box working Model and Package. However, when I added another set I am not sure what the heck to do to get it to work. I am able to select on Type but the Year box doesn’t populate based on New or Used.
Please any help.
Here is the code:
<script LANGUAGE=”JavaScript”>
<!– Original: Jerome Caron (
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com
<!– Begin
package = new Array(
new Array(
new Array(“RT”, ‘RT’),
new Array(“RTS”, “RTS”),
new Array(“RTL”, “RTL”),
new Array(“RTL with Moonroof”, “RTL with Moon roof”),
new Array(“RTL with Moonroof & Honda Satellite-Linked Navigation System™”, “RTL with Moonroof & Honda Satellite-Linked Navigation System™”)
),
new Array(
new Array(“Value Package”, ‘Value Package’),
new Array(“HX”, ‘HX’),
new Array(“LX”, “LX”),
new Array(“LX Special Edition”, “LX Special Edition”),
new Array(“EX”, “EX”),
new Array(“EX Special Edition”, “EX Special Edition”)
),
new Array(
new Array(“GX”, ‘GX’)
),
new Array(
new Array(“Hybrid”, ‘Hybrid’)
),
new Array(
new Array(“2WD LX”, ‘2WD LX’),
new Array(“4WD LX”, “4WD LX”),
new Array(“4WD EX”, “4WD EX”),
new Array(“4WD Special Edition”, “4WD Special Edition”)
),
new Array(
new Array(“2WD LX”, ‘2WD LX’),
new Array(“4WD LX”, “4WD LX”),
new Array(“2WD EX”, “2WD EX”),
new Array(“4WD EX”, “4WD EX”)
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem)
{
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i–) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End –>
</script>
<script LANGUAGE=”JavaScript”>
<!– Begin
year = new Array(
new Array(
new Array(“2006”, “2006”),
new Array(“2005”, “2005”)
),
new Array(
new Array(“2005”, ‘2005’),
new Array(“2004”, “2004”),
new Array(“2003”, “2003”),
new Array(“2002”, “2002”),
new Array(“2001”, “2001”),
new Array(“2000”, “2000”),
new Array(“1999”, “1999”),
new Array(“1998”, “1998”),
new Array(“1997”, “1997”),
new Array(“1996”, “1996”),
new Array(“1995”, “1995”)
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem)
{
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i–) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
// End –>
</script>
<meta name=”Microsoft Theme” content=”none, default”>
</head>
<body leftmargin=”0″ topmargin=”0″ marginwidth=”0″ marginheight=”0″ bgproperties=”fixed” background=”images/hondabkgrnd30.jpg”>
<!–webbot bot=”Include” U-Include=”includes/bannerpg2.htm” TAG=”BODY” –><div align=”left”>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ style=”border-collapse: collapse” bordercolor=”#111111″>
<tr>
<td rowspan=”3″ bgcolor=”#000066″ width=”150″ valign=”top”>
<img src=”images/clear_dot.gif” width=”150″ height=”8″>
<!–webbot bot=”Include” U-Include=”includes/left_info_box.htm” TAG=”BODY” –>
<p align=”center”> <!–webbot CLIENTSIDE bot=”Ws4FpEx” MODULEID=”‘Honda (Project)Service_off.xws'” PREVIEW=”<img src=’images/Service.gif?151651F8′ editor=’Webstyle4’ border=’0’>” startspan –><script src=”xaramenu.js”></script><script Webstyle4 src=”images/service.js”></script><noscript><img src=”images/Service.gif?151651F8″ editor=”Webstyle4″></noscript><!–webbot bot=”Ws4FpEx” endspan i-checksum=”18676″ –></p>
<p> </p>
<p> </p>
<!–webbot bot=”Include” U-Include=”includes/left_contact_box.htm” TAG=”BODY” –></td>
<td width=”35″ valign=”top”>
<img src=”images/tl_curve.gif” width=”35″ height=”35″></td>
<td width=”575″ valign=”top”>
<p align=”center”>
<script LANGUAGE=”JavaScript1.2″>
var months=new Array(13);
months[1]=”January”;
months[2]=”February”;
months[3]=”March”;
months[4]=”April”;
months[5]=”May”;
months[6]=”June”;
months[7]=”July”;
months[8]=”August”;
months[9]=”September”;
months[10]=”October”;
months[11]=”November”;
months[12]=”December”;
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)
year = year + 1900;
document.write(“<right>” + lmonth + ” “);
document.write(date + “, ” + year + “</right>”);
</script>
</td>
</tr>
<tr>
<td width=”35″> </td>
<td align=”left” valign=”top” width=”100%”>
<h1>Quick Quote:</h1>
<blockquote>
<form METHOD=”POST” ACTION=”
<input type=”hidden” name=”recipient” value=”
<input type=”hidden” name=”subject” value=”ONLINE QUICK QUOTE REQUEST”>
<input type=”hidden” name=”redirect” value=”
<input type=”hidden” name=”required” value=”Model,Package,type,year,Day_Phone,Name”>
<input type=”hidden” name=”print_blank_fields” value=”1″>
<input type=”hidden” name=”title” value=”QUICK QUOTE REQUEST”>
<input type=”hidden” name=”return_link_url” value=”
<input type=”hidden” name=”return_link_title” value=”Back to Main Page”>
<table border=”0″ cellspacing=”0″ style=”border-collapse: collapse” bordercolor=”#111111″ width=”500″ id=”AutoNumber2″ align=”left” cellpadding=”10″ height=”355″>
<tr>
<td width=”50%” height=”40″><b><font face=”Verdana”>
<font color=”#000066″ size=”2″>Model</font><font size=”2″ color=”#CE0000″>*</font></font><font color=”#000066″ size=”2″><font face=”Verdana”>:</font>
</font></b></td>
<td width=”50%” height=”40″>
<select NAME=”Model” onChange=”fillSelectFromArray(this.form.Package, ((this.selectedIndex == -1) ? null : package[this.selectedIndex-1]));”>
<option VALUE=”-1″>Select Model</option>
<option VALUE=”Ridgeline”>Ridgeline</option>
<option VALUE=”Accord Coupe”>Accord Coupe</option>
<option VALUE=”Accord Hybrid”>Accord Hybrid</option>
<option VALUE=”Accord Sedan”>Accord Sedan</option>
<option VALUE=”Civic Coupe”>Civic Coupe</option>
<option VALUE=”Civic GX NGV”>Civic GX NGV</option>
<option VALUE=”Civic Hybrid”>Civic Hybrid</option>
<option VALUE=”Civic Sedan”>Civic Sedan</option>
<option VALUE=”CR-V”>CR-V</option>
<option VALUE=”Pilot”>Pilot</option>
<option VALUE=”Odyssey”>Odyssey</option>
<option VALUE=”Insight”>Insight</option>
<option VALUE=”S2000″>S2000</option>
<option VALUE=”Element”>Element</option>
</select> </td>
</tr>
<tr>
<td width=”50%” height=”40″><b>
<font face=”Verdana” size=”2″ color=”#000066″>Trim Level Package<br>
</font></b></td>
<td width=”50%” height=”40″><select NAME=”Package” SIZE=”1″>
<option>Select Trim Package</option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>
<tr>
<td width=”50%” height=”40″><b>
<font face=”Verdana” size=”2″ color=”#000066″>Type:</font></b></td>
<td width=”50%” height=”40″>
<select NAME=”Type” onChange=”fillSelectFromArray(this.form.Year, ((this.selectedIndex == -1) ? null : year[this.selectedIndex-1]));”>
<option VALUE=”-1″>Select Type</option>
<option VALUE=”New”>New</option>
<option VALUE=”Used”>Used</option>
</select> <select NAME=”Year” SIZE=”1″>
<option>Select Year</option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>