Hi,
code gekürzt und wirr formatiert, naja...egal.
Probier das mal aus, sofern ich dich verstanden habe.
HTML-Code:
<!doctype html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
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;
}
TypeArray = new Array(
new Type(1, "HAUPTGRUPPE A"),
new Type(2, "HAUPTGRUPPE B")
);
StyleArray = new Array(
new Style(1, 1, "1.UNTERGRUPPE A"),
new Style(2, 1, "2.UNTERGRUPPE A"),
new Style(21, 2, "1.UNTERGRUPPE B"),
new Style(22, 2, "2.UNTERGRUPPE B")
);
function init(sel_type, sel_style){
document.product.id_type.options[0] = new Option("HAUPTGRUPPE");
document.product.id_style.options[0] = new Option("UNTERGRUPPE");
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++;
}
}
}
function ShowValue()
{
document.product.auswahl.value = document.product.id_style.options[document.product.id_style.selectedIndex].value+" "+
document.product.id_style.options[document.product.id_style.selectedIndex].text;
}
</script>
</head>
<body>
<form name="product" method="post" action="xy.php">
<select name="id_type" size="1" onChange="OnChange()"></select>
<select name="id_style" size="1" onChange="ShowValue()"></select>
<input type="text" name="auswahl" value="" >*
</form>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
init();
</SCRIPT>
</body>
</html>
MfG
CKaos