Sådan, som sagt pas på databasen !-)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>Smart selects</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK HREF="style/style.css" REL="stylesheet" TYPE="text/css">
<style type="text/css">
body{padding:10px;font-family:Tahoma,Verdana,Arial,sans-serif;text-align:center;background:#EBD3E2;line-height:1.5;overflow:hidden;}
</style>
<script type="text/javascript">
var arr = [
["Valg 1",[
["2. valg 1 (1)",[
["3. valg 1 (1-1)",
["4. valg 1 (1-1-1)","4. valg 2 (1-1-1)","4. valg 3 (1-1-1)"]],
["3. valg 2 (1-1)",
["4. valg 1 (1-1-2)","4. valg 2 (1-1-2)","4. valg 3 (1-1-2)"]],
["3. valg 3 (1-1)",
["4. valg 1 (1-1-3)","4. valg 2 (1-1-3)","4. valg 3 (1-1-3)"]],
["3. valg 4 (1-1)",
["4. valg 1 (1-1-4)","4. valg 2 (1-1-4)","4. valg 3 (1-1-4)"]]]],
["2. valg 2 (1)",[
["3. valg 1 (1-2)",
["4. valg 1 (1-2-1)","4. valg 2 (1-2-1)","4. valg 3 (1-2-1)"]],
["3. valg 2 (1-2)",
["4. valg 1 (1-2-2)","4. valg 2 (1-2-2)","4. valg 3 (1-2-2)"]],
["3. valg 3 (1-2)",
["4. valg 1 (1-2-3)","4. valg 2 (1-2-3)","4. valg 3 (1-2-3)"]]]],
["2. valg 3 (1)",[
["3. valg 1 (1-2)",
["4. valg 1 (1-2-1)","4. valg 2 (1-2-1)","4. valg 3 (1-2-1)"]],
["3. valg 2 (1-2)",
["4. valg 1 (1-2-2)","4. valg 2 (1-2-2)","4. valg 3 (1-2-2)"]],
["3. valg 3 (1-2)",
["4. valg 1 (1-2-3)","4. valg 2 (1-2-3)","4. valg 3 (1-2-3)"]]]]]],
["Valg 2",[
["2. valg 1 (2)",[
["3. valg 1 (2-1)",
["4. valg 1 (2-1-1)","4. valg 2 (2-1-1)","4. valg 3 (2-1-1)"]],
["3. valg 2 (2-1)",
["4. valg 1 (2-1-2)","4. valg 2 (2-1-2)","4. valg 3 (2-1-2)"]],
["3. valg 3 (2-1)",
["4. valg 1 (2-1-3)","4. valg 2 (2-1-3)","4. valg 3 (2-1-3)"]],
["3. valg 4 (2-1)",
["4. valg 1 (2-1-4)","4. valg 2 (2-1-4)","4. valg 3 (2-1-4)"]]]],
["2. valg 2 (2)",[
["3. valg 1 (2-2)",
["4. valg 1 (2-2-1)","4. valg 2 (2-2-1)","4. valg 3 (2-2-1)"]],
["3. valg 2 (2-2)",
["4. valg 1 (2-2-2)","4. valg 2 (2-2-2)","4. valg 3 (2-2-2)"]],
["3. valg 3 (2-2)",
["4. valg 1 (2-2-3)","4. valg 2 (2-2-3)","4. valg 3 (2-2-3)"]]]],
["2. valg 3 (2)",[
["3. valg 1 (2-2)",
["4. valg 1 (2-2-1)","4. valg 2 (2-2-1)","4. valg 3 (2-2-1)"]],
["3. valg 2 (2-2)",
["4. valg 1 (2-2-2)","4. valg 2 (2-2-2)","4. valg 3 (2-2-2)"]],
["3. valg 3 (2-2)",
["4. valg 1 (2-2-3)","4. valg 2 (2-2-3)","4. valg 3 (2-2-3)"]]]]]],
["Valg 3",[
["2. valg 1 (3)",[
["3. valg 1 (3-1)",
["4. valg 1 (3-1-1)","4. valg 2 (3-1-1)","4. valg 3 (3-1-1)"]],
["3. valg 2 (3-1)",
["4. valg 1 (3-1-2)","4. valg 2 (3-1-2)","4. valg 3 (3-1-2)"]],
["3. valg 3 (3-1)",
["4. valg 1 (3-1-3)","4. valg 2 (3-1-3)","4. valg 3 (3-1-3)"]],
["3. valg 4 (3-1)",
["4. valg 1 (3-1-4)","4. valg 2 (3-1-4)","4. valg 3 (3-1-4)"]]]],
["2. valg 2 (3)",[
["3. valg 1 (3-2)",
["4. valg 1 (3-2-1)","4. valg 2 (3-2-1)","4. valg 3 (3-2-1)"]],
["3. valg 2 (3-2)",
["4. valg 1 (3-2-2)","4. valg 2 (3-2-2)","4. valg 3 (3-2-2)"]],
["3. valg 3 (3-2)",
["4. valg 1 (3-2-3)","4. valg 2 (3-2-3)","4. valg 3 (3-2-3)"]]]],
["2. valg 3 (3)",[
["3. valg 1 (3-2)",
["4. valg 1 (3-2-1)","4. valg 2 (3-2-1)","4. valg 3 (3-2-1)"]],
["3. valg 2 (3-2)",
["4. valg 1 (3-2-2)","4. valg 2 (3-2-2)","4. valg 3 (3-2-2)"]],
["3. valg 3 (3-2)",
["4. valg 1 (3-2-3)","4. valg 2 (3-2-3)","4. valg 3 (3-2-3)"]]]]]]
];
//alert(arr1[1][1])
function initSels(){
createOpts(document.getElementById('sel1'));
}
function createOpts(sel){
var s = new Array();
var num = 0, txt = "arr";
var ar = opt = null;
var n = sel.selectedIndex;
var args = createOpts.arguments.length;
for(var i=1;args>i;i++){
s[i-1] = document.getElementById(createOpts.arguments[i]);
if(s[i-1]==sel)num=i;
}
if(args>1){
if(s[num])sel = s[num];
else return;
}
if(n==0&&args>1){
for(i=num;args>i+1;i++){
s[i].length = 0;
opt = document.createElement('OPTION');
s[i].appendChild(opt);
opt.value = "";
opt.text = "\74-- Vælg --";
}
return true
};
for(i=0;num>i;i++){
txt+="["+(s[i].selectedIndex-1)+"][1]";
}
ar = eval(txt);
sel.length = 0;
opt = document.createElement('OPTION');
sel.appendChild(opt);
opt.value = "";
opt.text = "-- Vælg --";
for(i=0;ar.length>i;i++){
opt = document.createElement('OPTION');
sel.appendChild(opt);
if(typeof ar[i] == 'object'){
opt.value = ar[i][0];
opt.text = ar[i][0];
}else{
opt.value = ar[i];
opt.text = ar[i];
}
}
if(args>num+2){
for(i=num+1;args-1>i;i++){
s[i].length = 0;
opt = document.createElement('OPTION');
s[i].appendChild(opt);
opt.value = "";
opt.text = "\74-- Vælg --";
}
}
}
window.onload = function(){
initSels();
}
</script>
</head>
<body>
<h1 style=>Working demo #4 beta2 - 4 afhængige</h1>
Afhængige selects<br><br>
Fire afhængige selects:
<select name="sel1" id="sel1" onchange="createOpts(this,'sel1','sel2','sel3','sel4');">
<option value="" selected>Vis alle</option>
</select>
<select name="sel2" id="sel2" onchange="createOpts(this,'sel1','sel2','sel3','sel4');">
<option value="" selected><-- Vælg --</option>
</select>
<select name="sel3" id="sel3" onchange="createOpts(this,'sel1','sel2','sel3','sel4');">
<option value="" selected><-- Vælg --</option>
</select>
<select name="sel4" id="sel4">
<option value="" selected><-- Vælg --</option>
</select>
<br><br>
</body>
</html>