kiedys cos takiego pisalem, na szczescie jeszcze to mam. Musisz sobie przerobic
<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;
}
/* ################### DANE DO EDYCJI ############## */
TypeArray = new Array(
new Type(1, "Dolnośląskie"),
new Type(2, "Wielkopolskie")
);
StyleArray = new Array(
new Style(1, 1, "Szkoła_1"), // do Dolnośląskiego
new Style(2, 1, "Szkoła_2"),
new Style(3, 2, "Szkoła_3"), // Do Wielkopolskiego
new Style(4, 2, "Szkoła_4")
);
/* ############### KONIEC DANYCH DO EDYCJI ############### */
function init(sel_type, sel_style){
document.product.id_type.options[0] = new Option("[ Województwo ]");
document.product.id_style.options[0] = new Option("[ Szkoła ]");
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++;
}
}
}
//-->
<select name="id_type" size="1" style="width: 150px;" onChange="OnChange()"></select>
<select name="id_style" size="1" style="width: 350px;"></select>
<input type="submit" value="Głosuj" name="glosuj">
<script LANGUAGE="JavaScript" TYPE="text/javascript"> init();