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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two linked drop down boxes 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,
I came across the following script that has two dropdown boxes the category and subcategory. Works great, but if I try to copy the code to add more boxes the <noscript> part hides everything and only shows the first two boxes (category and subcategory) is there a way around this?
Code:
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript">
function dropdownlist(listindex)
{

document.formname.subcategory.options.length = 0;
switch (listindex)
{

case "Missing" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Set Screws","Set Screws");
document.formname.subcategory.options[2]=new Option("Operations","Operations");

break;

case "Surface" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Finish","Finish");
document.formname.subcategory.options[2]=new Option("Blemished","Blemished");
document.formname.subcategory.options[3]=new Option("Chipped","Chipped");
document.formname.subcategory.options[4]=new Option("Color","Color");

break;

case "Flash" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("In Thread","In Thread");
document.formname.subcategory.options[2]=new Option("On Part","On Part");

break;

case "Insert" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Wrong Thread","Wrong Thread");
document.formname.subcategory.options[2]=new Option("Tight Thread","Tight Thread");
document.formname.subcategory.options[3]=new Option("Loose Thread","Loose Thread");

break;

case "Defective" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Cracked","Cracked");
document.formname.subcategory.options[2]=new Option("Undercured","Undercured");
document.formname.subcategory.options[3]=new Option("Scratches","Scratches");
document.formname.subcategory.options[4]=new Option("Incorrect Dimensions","Incorrect Dimensions");

break;

case "Shipping" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Shortage","Shortage");
document.formname.subcategory.options[2]=new Option("Overshipment","Overshipment");
document.formname.subcategory.options[3]=new Option("Wrong Parts","Wrong Parts");
document.formname.subcategory.options[4]=new Option("Mixed Parts","Mixed Parts");
document.formname.subcategory.options[5]=new Option("Damaged By Carrier","Damaged By Carrier");

break;

case "Return For Rework" :
document.formname.subcategory.options[0]=new Option("","");

break;

case "Pricing Error" :
document.formname.subcategory.options[0]=new Option("","");

break;


}
return true;
}
</script>
</head>
<title>Dynamic Drop Down List</title>
<body>

<form id="formname" name="formname" method="post" action="submitform.asp" >
<table width="50%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="20%" align="right" valign="middle">Category :</td>
<td width="27%" rowspan="3" align="left" valign="middle"><select name="codenumcomplaint1" id="codenumcomplaint1" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);">
  <option value="">Select Category</option>
  <option value="Defective">Defective</option>
  <option value="Flash">Flash</option>
  <option value="Insert">Insert</option>
  <option value="Missing">Missing</option>
  <option value="Pricing Error">Pricing Error</option>
  <option value="Return For Rework">Return For Rework</option>
  <option value="Shipping">Shipping</option>
  <option value="Surface">Surface</option>
</select></td><td width="53%" rowspan="3" align="left" valign="middle"><p>
  <script type="text/javascript" language="JavaScript">
document.write('<select name="subcategory"><option value="">Select Sub-Category</option></select>')
</script>

  <noscript>

    <select name="subcategory" id="subcategory" >
      <option value="">Select Sub-Category</option>
    </select>
</p>
 
Hi

I do not understand what exactly you want. Anyway, that JavaScript [tt]switch[/tt] looks horrible. Personally I would rewrite it as this :
JavaScript:
[b]var[/b] cat[teal]=[/teal][teal]{[/teal]
  [green][i]'Missing'[/i][/green][teal]:[[/teal][green][i]'Set Screws'[/i][/green][teal],[/teal][green][i]'Operations'[/i][/green][teal]],[/teal]
  [green][i]'Surface'[/i][/green][teal]:[[/teal][green][i]'Finish'[/i][/green][teal],[/teal][green][i]'Blemished'[/i][/green][teal],[/teal][green][i]'Chipped'[/i][/green][teal],[/teal][green][i]'Color'[/i][/green][teal]],[/teal]
  [green][i]'Flash'[/i][/green][teal]:[[/teal][green][i]'In Thread'[/i][/green][teal],[/teal][green][i]'On Part'[/i][/green][teal]],[/teal]
  [green][i]'Insert'[/i][/green][teal]:[[/teal][green][i]'Wrong Thread'[/i][/green][teal],[/teal][green][i]'Tight Thread'[/i][/green][teal],[/teal][green][i]'Loose Thread'[/i][/green][teal]],[/teal]
  [green][i]'Defective'[/i][/green][teal]:[[/teal][green][i]'Cracked'[/i][/green][teal],[/teal][green][i]'Undercured'[/i][/green][teal],[/teal][green][i]'Scratches'[/i][/green][teal],[/teal][green][i]'Incorrect Dimensions'[/i][/green][teal]],[/teal]
  [green][i]'Shipping'[/i][/green][teal]:[[/teal][green][i]'Shortage'[/i][/green][teal],[/teal][green][i]'Overshipment'[/i][/green][teal],[/teal][green][i]'Wrong Parts'[/i][/green][teal],[/teal][green][i]'Mixed Parts'[/i][/green][teal],[/teal][green][i]'Damaged By Carrier'[/i][/green][teal]],[/teal]
  [green][i]'Return For Rework'[/i][/green][teal]:[],[/teal]
  [green][i]'Pricing Error'[/i][/green][teal]:[][/teal]
[teal]}[/teal]

[b]function[/b] [COLOR=darkgoldenrod]dropdownlist[/color][teal]([/teal]listindex[teal])[/teal]
[teal]{[/teal]
  document[teal].[/teal]formname[teal].[/teal]subcategory[teal].[/teal]options[teal].[/teal]length[teal]=[/teal][purple]1[/purple][teal];[/teal]
  [b]for[/b] [teal]([/teal][b]var[/b] i[teal]=[/teal][purple]0[/purple][teal],[/teal]l[teal]=[/teal]cat[teal][[/teal]listindex[teal]].[/teal]length[teal];[/teal]i[teal]<[/teal]l[teal];[/teal]i[teal]++)[/teal]
    document[teal].[/teal]formname[teal].[/teal]subcategory[teal].[/teal]options[teal][[/teal]i[teal]+[/teal][purple]1[/purple][teal]]=[/teal][b]new[/b] [COLOR=darkgoldenrod]Option[/color][teal]([/teal]cat[teal][[/teal]listindex[teal]][[/teal]i[teal]],[/teal]cat[teal][[/teal]listindex[teal]][[/teal]i[teal]]);[/teal]
  [b]return[/b] [b]true[/b][teal];[/teal]
[teal]}[/teal]
Your code ends suddenly. Is there something missing ?

Feherke.
 
the whole code looks like this
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript">
function dropdownlist(listindex)
{

document.formname.subcategory.options.length = 0;
switch (listindex)
{

case "Missing" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Set Screws","Set Screws");
document.formname.subcategory.options[2]=new Option("Operations","Operations");

break;

case "Surface" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Finish","Finish");
document.formname.subcategory.options[2]=new Option("Blemished","Blemished");
document.formname.subcategory.options[3]=new Option("Chipped","Chipped");
document.formname.subcategory.options[4]=new Option("Color","Color");

break;

case "Flash" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("In Thread","In Thread");
document.formname.subcategory.options[2]=new Option("On Part","On Part");

break;

case "Insert" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Wrong Thread","Wrong Thread");
document.formname.subcategory.options[2]=new Option("Tight Thread","Tight Thread");
document.formname.subcategory.options[3]=new Option("Loose Thread","Loose Thread");

break;

case "Defective" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Cracked","Cracked");
document.formname.subcategory.options[2]=new Option("Undercured","Undercured");
document.formname.subcategory.options[3]=new Option("Scratches","Scratches");
document.formname.subcategory.options[4]=new Option("Incorrect Dimensions","Incorrect Dimensions");

break;

case "Shipping" :
document.formname.subcategory.options[0]=new Option("Select Sub-Category","");
document.formname.subcategory.options[1]=new Option("Shortage","Shortage");
document.formname.subcategory.options[2]=new Option("Overshipment","Overshipment");
document.formname.subcategory.options[3]=new Option("Wrong Parts","Wrong Parts");
document.formname.subcategory.options[4]=new Option("Mixed Parts","Mixed Parts");
document.formname.subcategory.options[5]=new Option("Damaged By Carrier","Damaged By Carrier");

break;

case "Return For Rework" :
document.formname.subcategory.options[0]=new Option("","");

break;

case "Pricing Error" :
document.formname.subcategory.options[0]=new Option("","");

break;


}
return true;
}
</script>
</head>
<title>Dynamic Drop Down List</title>
<body>

<form id="formname" name="formname" method="post" action="submitform.asp" >
<table width="50%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="20%" align="right" valign="middle">Category :</td>
<td width="27%" rowspan="3" align="left" valign="middle"><select name="codenumcomplaint1" id="codenumcomplaint1" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);">
  <option value="">Select Category</option>
  <option value="Defective">Defective</option>
  <option value="Flash">Flash</option>
  <option value="Insert">Insert</option>
  <option value="Missing">Missing</option>
  <option value="Pricing Error">Pricing Error</option>
  <option value="Return For Rework">Return For Rework</option>
  <option value="Shipping">Shipping</option>
  <option value="Surface">Surface</option>
</select></td>
<td width="53%" rowspan="3" align="left" valign="middle"><p>
  <script type="text/javascript" language="JavaScript">
document.write('<select name="subcategory"><option value="">Select Sub-Category</option></select>')
</script>

  <noscript>

    <select name="subcategory" id="subcategory" >
      <option value="">Select Sub-Category</option>
    </select>
</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;  </p>
  </noscript></td>
</tr>
<tr>
  <td align="right" valign="middle">&nbsp;</td>
</tr>
<tr>
  <td align="right" valign="middle">&nbsp;</td>
</tr>
</table>

</form> 
 

</body>
</html>[code]
 
I apologize I srewed up on the closing braket. Sorry!!
 
waht I am trying to accomplish is to have
3 category boxes and 3 subcategory

category1 subcategory1
category2 subcategory2
category3 subcategory3
 
Hi

evr72 said:
3 category boxes and 3 subcategory

category1 subcategory1
category2 subcategory2
category3 subcategory3
You mean, 6 [tt]select[/tt] elements arranged in 3 pairs ? And the relation between the 2[sup]nd[/sup] and 3[sup]rd[/sup] pairs parts is the same as in case of the 1[sup]st[/sup] pair ? And there is no relation between those 3 pair ? If yes, then you only have to tell the dropdownlist() function which pair's subcategory has to be populated :
JavaScript:
[b]var[/b] cat[teal]=[/teal][teal]{[/teal]
  [green][i]'codenumcomplaint1'[/i][/green][teal]:[/teal][teal]{[/teal]
    [green][i]'Missing'[/i][/green][teal]:[[/teal][green][i]'Set Screws'[/i][/green][teal],[/teal][green][i]'Operations'[/i][/green][teal]],[/teal]
    [green][i]'Surface'[/i][/green][teal]:[[/teal][green][i]'Finish'[/i][/green][teal],[/teal][green][i]'Blemished'[/i][/green][teal],[/teal][green][i]'Chipped'[/i][/green][teal],[/teal][green][i]'Color'[/i][/green][teal]],[/teal]
    [green][i]'Flash'[/i][/green][teal]:[[/teal][green][i]'In Thread'[/i][/green][teal],[/teal][green][i]'On Part'[/i][/green][teal]],[/teal]
    [green][i]'Insert'[/i][/green][teal]:[[/teal][green][i]'Wrong Thread'[/i][/green][teal],[/teal][green][i]'Tight Thread'[/i][/green][teal],[/teal][green][i]'Loose Thread'[/i][/green][teal]],[/teal]
    [green][i]'Defective'[/i][/green][teal]:[[/teal][green][i]'Cracked'[/i][/green][teal],[/teal][green][i]'Undercured'[/i][/green][teal],[/teal][green][i]'Scratches'[/i][/green][teal],[/teal][green][i]'Incorrect Dimensions'[/i][/green][teal]],[/teal]
    [green][i]'Shipping'[/i][/green][teal]:[[/teal][green][i]'Shortage'[/i][/green][teal],[/teal][green][i]'Overshipment'[/i][/green][teal],[/teal][green][i]'Wrong Parts'[/i][/green][teal],[/teal][green][i]'Mixed Parts'[/i][/green][teal],[/teal][green][i]'Damaged By Carrier'[/i][/green][teal]],[/teal]
    [green][i]'Return For Rework'[/i][/green][teal]:[],[/teal]
    [green][i]'Pricing Error'[/i][/green][teal]:[][/teal]
  [teal]}[/teal][teal],[/teal]
  [green][i]'animal'[/i][/green][teal]:[/teal][teal]{[/teal]
    [green][i]'Mammal'[/i][/green][teal]:[[/teal][green][i]'Cat'[/i][/green][teal],[/teal][green][i]'Dog'[/i][/green][teal],[/teal][green][i]'Rat'[/i][/green][teal]],[/teal]
    [green][i]'Fish'[/i][/green][teal]:[[/teal][green][i]'Shark'[/i][/green][teal],[/teal][green][i]'Tuna'[/i][/green][teal]],[/teal]
    [green][i]'Insect'[/i][/green][teal]:[[/teal][green][i]'Fly'[/i][/green][teal],[/teal][green][i]'Spider'[/i][/green][teal]][/teal]
  [teal]}[/teal][teal],[/teal]
  [green][i]'plant'[/i][/green][teal]:[/teal][teal]{[/teal]
    [green][i]'Flower'[/i][/green][teal]:[[/teal][green][i]'Orchid'[/i][/green][teal],[/teal][green][i]'Rose'[/i][/green][teal]],[/teal]
    [green][i]'Tree'[/i][/green][teal]:[[/teal][green][i]'Elm'[/i][/green][teal],[/teal][green][i]'Maple'[/i][/green][teal],[/teal][green][i]'Oak'[/i][/green][teal]][/teal]
  [teal]}[/teal]
[teal]}[/teal]

[b]function[/b] [COLOR=darkgoldenrod]dropdownlist[/color][teal]([/teal]listname[teal],[/teal]listindex[teal])[/teal]
[teal]{[/teal]
  [b]var[/b] subcat[teal]=[/teal]document[teal].[/teal]formname[teal].[/teal]elements[teal][[/teal][green][i]'subcategory'[/i][/green][teal]+[/teal]listname[teal]];[/teal]
  subcat[teal].[/teal]options[teal].[/teal]length[teal]=[/teal][purple]1[/purple][teal];[/teal]
  [b]if[/b] [teal]([/teal]listindex [b]in[/b] cat[teal][[/teal]listname[teal]])[/teal]
    [b]for[/b] [teal]([/teal][b]var[/b] i[teal]=[/teal][purple]0[/purple][teal],[/teal]l[teal]=[/teal]cat[teal][[/teal]listname[teal]][[/teal]listindex[teal]].[/teal]length[teal];[/teal]i[teal]<[/teal]l[teal];[/teal]i[teal]++)[/teal]
      subcat[teal].[/teal]options[teal][[/teal]i[teal]+[/teal][purple]1[/purple][teal]]=[/teal][b]new[/b] [COLOR=darkgoldenrod]Option[/color][teal]([/teal]cat[teal][[/teal]listname[teal]][[/teal]listindex[teal]][[/teal]i[teal]],[/teal]cat[teal][[/teal]listname[teal]][[/teal]listindex[teal]][[/teal]i[teal]]);[/teal]
  [b]return[/b] [b]true[/b][teal];[/teal]
[teal]}[/teal]
HTML:
[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"codenumcomplaint1"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"codenumcomplaint1"[/i][/green] [maroon]onchange[/maroon][teal]=[/teal][green][i]"dropdownlist(this.name,this.options[this.selectedIndex].value);"[/i][/green][b]>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]""[/i][/green][b]>[/b]Select Category[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Defective"[/i][/green][b]>[/b]Defective[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Flash"[/i][/green][b]>[/b]Flash[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Insert"[/i][/green][b]>[/b]Insert[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Missing"[/i][/green][b]>[/b]Missing[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Pricing Error"[/i][/green][b]>[/b]Pricing Error[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Return For Rework"[/i][/green][b]>[/b]Return For Rework[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Shipping"[/i][/green][b]>[/b]Shipping[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Surface"[/i][/green][b]>[/b]Surface[b]</option>[/b]
[b]</select>[/b]
[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"subcategorycodenumcomplaint1"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"subcategorycodenumcomplaint1"[/i][/green][b]>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]""[/i][/green][b]>[/b]Select Sub-Category[b]</option>[/b]
[b]</select>[/b]

[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"animal"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"animal"[/i][/green] [maroon]onchange[/maroon][teal]=[/teal][green][i]"dropdownlist(this.name,this.options[this.selectedIndex].value)"[/i][/green][b]>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]""[/i][/green][b]>[/b]Select Category[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Mammal"[/i][/green][b]>[/b]Mammal[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Fish"[/i][/green][b]>[/b]Fish[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Insect"[/i][/green][b]>[/b]Insect[b]</option>[/b]
[b]</select>[/b]
[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"subcategoryanimal"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"subcategoryanimal"[/i][/green][b]>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]""[/i][/green][b]>[/b]Select Sub-Category[b]</option>[/b]
[b]</select>[/b]

[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"plant"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"plant"[/i][/green] [maroon]onchange[/maroon][teal]=[/teal][green][i]"dropdownlist(this.name,this.options[this.selectedIndex].value)"[/i][/green][b]>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]""[/i][/green][b]>[/b]Select Category[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Flower"[/i][/green][b]>[/b]Flower[b]</option>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]"Tree"[/i][/green][b]>[/b]Tree[b]</option>[/b]
[b]</select>[/b]
[b]<select[/b] [maroon]name[/maroon][teal]=[/teal][green][i]"subcategoryplant"[/i][/green] [maroon]id[/maroon][teal]=[/teal][green][i]"subcategoryplant"[/i][/green][b]>[/b]
  [b]<option[/b] [maroon]value[/maroon][teal]=[/teal][green][i]""[/i][/green][b]>[/b]Select Sub-Category[b]</option>[/b]
[b]</select>[/b]
By the way, do not specify the [tt]javascript:[/tt] pseudo-protocol in event handler calls.

Feherke.
 
thanks feherke,
I can see the categories but no subcategories, the error on the page:
Code:
line 27 character 3 Error: 'document.formname.elements' is null or not an object
Code:0
 
Hi

Well, it should work if the rest of the HTML was not altered. While it not works, you certainly changed something. And if you changed something, you will have to show us your new HTML code otherwise we can not guess the reason of the error.

( Needless to say, it works for me. )

Feherke.
 
this is what I did

I added the
Code:
<script language="javascript"> </script>  to the beginning of the javascript code
then  the
<body></body> to the second part of the code

the code below is what I have on my html page
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
var cat={
  'codenumcomplaint1':{
    'Missing':['Set Screws','Operations'],
    'Surface':['Finish','Blemished','Chipped','Color'],
    'Flash':['In Thread','On Part'],
    'Insert':['Wrong Thread','Tight Thread','Loose Thread'],
    'Defective':['Cracked','Undercured','Scratches','Incorrect Dimensions'],
    'Shipping':['Shortage','Overshipment','Wrong Parts','Mixed Parts','Damaged By Carrier'],
    'Return For Rework':[],
    'Pricing Error':[]
  },
  'animal':{
    'Mammal':['Cat','Dog','Rat'],
    'Fish':['Shark','Tuna'],
    'Insect':['Fly','Spider']
  },
  'plant':{
    'Flower':['Orchid','Rose'],
    'Tree':['Elm','Maple','Oak']
  }
}

function dropdownlist(listname,listindex)
{
  var subcat=document.formname.elements['subcategory'+listname];
  subcat.options.length=1;
  if (listindex in cat[listname])
    for (var i=0,l=cat[listname][listindex].length;i<l;i++)
      subcat.options[i+1]=new Option(cat[listname][listindex][i],cat[listname][listindex][i]);
  return true;
}
</script>
</head>

<body>

<select name="codenumcomplaint1" id="codenumcomplaint1" onchange="dropdownlist(this.name,this.options[this.selectedIndex].value);">
  <option value="">Select Category</option>
  <option value="Defective">Defective</option>
  <option value="Flash">Flash</option>
  <option value="Insert">Insert</option>
  <option value="Missing">Missing</option>
  <option value="Pricing Error">Pricing Error</option>
  <option value="Return For Rework">Return For Rework</option>
  <option value="Shipping">Shipping</option>
  <option value="Surface">Surface</option>
</select>
<select name="subcategorycodenumcomplaint1" id="subcategorycodenumcomplaint1">
  <option value="">Select Sub-Category</option>
</select>

<select name="animal" id="animal" onchange="dropdownlist(this.name,this.options[this.selectedIndex].value)">
  <option value="">Select Category</option>
  <option value="Mammal">Mammal</option>
  <option value="Fish">Fish</option>
  <option value="Insect">Insect</option>
</select>
<select name="subcategoryanimal" id="subcategoryanimal">
  <option value="">Select Sub-Category</option>
</select>

<select name="plant" id="plant" onchange="dropdownlist(this.name,this.options[this.selectedIndex].value)">
  <option value="">Select Category</option>
  <option value="Flower">Flower</option>
  <option value="Tree">Tree</option>
</select>
<select name="subcategoryplant" id="subcategoryplant">
  <option value="">Select Sub-Category</option>
</select>
</body>
</html>
 
OHHHHHHH I am sorry I should have figured that one out

I really appreciate it!!!!!!!!!! Thank you!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top