Connected Combo Boxes
 
This script contains code for 2 combo boxes, which are connected to each other.
The original code is from http://javascript.internet.com. The example contains categories from lookass.ch

Insert this code into the body of your html document:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
// Initialize class for Type and Style
function Type(id, type){
this.id = id;
this.type = type;
}
function Style(id, id_type, style){
this.id = id;
this.id_type = id_type;
this.style = style;
}
  // Initialize Array's Data for Type and Style
TypeArray = new Array(
new Type(1, "Database"),
new Type(2, "Development"),
new Type(3, "Encyclopedia"),
new Type(4, "Linux"),
new Type(5, "Macintosh"),
new Type(6, "Microsoft Products"),
new Type(7, "Security"),
new Type(8, "Software"),
new Type(9, "Webdesign"),
new Type(10, "Webserver")
);
StyleArray = new Array(
new Style(1, 1, "MySQL Function Reference"),
new Style(2, 1, "MySQL General"),
new Style(3, 2, "Cocoa"),
new Style(4, 2, "Cplusplus General"),
new Style(5, 2, "Java"),
new Style(6, 2, "Java Script"),
new Style(7, 2, "PHP Function Reference"),
new Style(8, 2, "PHP General"),
new Style(9, 2, "PHP Scripts"),
new Style(10, 3, "D"),
new Style(11, 4, "Dedicated Linux Gameservers"),
new Style(12, 4, "Distribution Debian Woody"),
new Style(13, 4, "Distribution Knoppix"),
new Style(14, 4, "Distribution Mandriva 2006"),
new Style(15, 4, "Distribution SUSE 9.0 and 9.1"),
new Style(16, 4, "Linux General"),
new Style(17, 4, "Shellscript"),
new Style(18, 5, "Hardware"),
new Style(19, 5, "Unix"),
new Style(20, 6, "Command Line"),
new Style(21, 6, "SharePoint Portal Server 2003"),
new Style(22, 6, "Windows XP Professional"),
new Style(23, 7, "Spyware"),
new Style(24, 7, "Windows"),
new Style(25, 8, "Internet"),
new Style(26, 9, "CSS"),
new Style(27, 9, "Flash MX / 2004"),
new Style(28, 9, "html"),
new Style(29, 10, "Apache"),
new Style(30, 10, "Confixx"),
new Style(31, 10, "ProFTPD"),
new Style(32, 10, "Webserver General")
);
function init(sel_type, sel_style){
document.product.id_type.options[0] = new Option("");
document.product.id_style.options[0] = new Option("");
for(i = 1; i <= TypeArray.length; i++){
document.product.id_type.options[i] = new Option(TypeArray[i-1].type, TypeArray[i-1].id);
if(TypeArray[i-1].id == sel_type)
document.product.id_type.options[i].selected = true;
}
OnChange(sel_style);
}
function OnChange(sel_style){
sel_type_index = document.product.id_type.selectedIndex;
sel_type_value = parseInt(document.product.id_type[sel_type_index].value);
for(i = document.product.id_style.length - 1; i > 0; i--)
document.product.id_style.options[i] = null;
j=1;
for(i = 1; i <= StyleArray.length; i++){
if(StyleArray[i-1].id_type == sel_type_value){
document.product.id_style.options[j] = new Option(StyleArray[i-1].style, StyleArray[i-1].id);
if(StyleArray[i-1].id == sel_style) document.product.id_style.options[j].selected = true;
j++;
}
}
}
//-->
</SCRIPT>

<form name="product" id="entryform" method="post">
<select class="home-text" style="width: 400px;" name="id_type" size="1" onChange="OnChange()"></select><br>
<select class="home-text" style="width: 400px;" name="id_style" size="1"></select>
</form>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
// init(5, 31); // Initialize comboboxes by selected sel_type and sel_style
init();     // Default initialize comboboxes for Type and Style
//-->
</SCRIPT>
 
admin / Dec 01, 2005
   
 
 
Login: 
Pass: 
 
 
     
     
2004 - 2019 / lookass.ch
makememad@lookass.ch