Tak til alle for hjælp. Jeg ledte på nettet og fandt, efter omfattende test,
et script, som jeg synes virker godt til formålet. Det gengiver jeg he
nedenfor (som det ser ud efter at jeg har puttet data ind i det::
------------------------------------------------------------------------------------
I head:
<script language="javascript" src="scripts/list.js"></script>
Formen:
<SELECT NAME="vej" onChange="SelectSubCat();" >
<Option value="">Vej</option>
</SELECT>
<SELECT id="SubCat" NAME="Nummer">
<Option value="10000">Nummer</option>
</SELECT>
-------------------------------------------------------------------------------------
Javascript, som includeres:
function fillCategory(){
// this function is used to fill the category list on load
addOption(document.membership.vej, "Banholmvej", "Banholmvej", "");
addOption(document.membership.vej, "Hansstedvej", "Hansstedvej", "");
addOption(document.membership.vej, "Maribovej", "Maribovej", "");
addOption(document.membership.vej, "Nakskovvej", "Nakskovvej", "");
addOption(document.membership.vej, "Nystedvej", "Nystedvej", "");
addOption(document.membership.vej, "Rødbyvej", "Rødbyvej", "");
addOption(document.membership.vej, "Sakskøbingvej", "Sakskøbingvej", "");
addOption(document.membership.vej, "Vigerslevvej", "Vigerslevvej", "");
}
function SelectSubCat(){
// ON selection of vej this function will work
removeAllOptions(document.membership.SubCat);
addOption(document.membership.SubCat, "", "Nummer", "");
if(document.membership.vej.value == 'Banholmvej'){
addOption(document.membership.SubCat,"2", "2");
addOption(document.membership.SubCat,"4", "4");
addOption(document.membership.SubCat,"11", "11");
addOption(document.membership.SubCat,"12", "12");
}
if(document.membership.vej.value == 'Hansstedvej'){
addOption(document.membership.SubCat,"1", "1");
addOption(document.membership.SubCat,"3", "3");
addOption(document.membership.SubCat,"4", "4");
}
if(document.membership.vej.value == 'Maribovej'){
addOption(document.membership.SubCat,"2", "2");
addOption(document.membership.SubCat,"4", "4");
addOption(document.membership.SubCat,"28", "29");
addOption(document.membership.SubCat,"30", "30");
}
if(document.membership.vej.value == 'Nakskovvej'){
addOption(document.membership.SubCat,"75", "75");
addOption(document.membership.SubCat,"113", "113");
addOption(document.membership.SubCat,"114", "114");
addOption(document.membership.SubCat,"146", "146");
addOption(document.membership.SubCat,"148", "148");
addOption(document.membership.SubCat,"150", "150");
}
if(document.membership.vej.value == 'Nystedvej'){
addOption(document.membership.SubCat,"28", "118");
addOption(document.membership.SubCat,"55", "142");
addOption(document.membership.SubCat,"57", "144");
addOption(document.membership.SubCat,"59", "146");
}
if(document.membership.vej.value == 'Rødbyvej'){
addOption(document.membership.SubCat,"2", "2");
addOption(document.membership.SubCat,"3", "3");
addOption(document.membership.SubCat,"7", "7", "");
}
if(document.membership.vej.value == 'Sakskøbingvej'){
addOption(document.membership.SubCat,"1", "1");
addOption(document.membership.SubCat,"2", "2");
addOption(document.membership.SubCat,"6", "6", "");
}
if(document.membership.vej.value == 'Vigerslevvej'){
addOption(document.membership.SubCat,"59 A", "59 A");
addOption(document.membership.SubCat,"59 B", "59 B");
addOption(document.membership.SubCat,"103", "103");
addOption(document.membership.SubCat,"105", "105");
}
}
function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}}
function addOption(selectbox, value, text )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
--------------------------------------------------------------------------
Ovenstående script virker perfekt i IE, så det holder jeg mig til. Jeg siger
igen mange tak for jeres forslag, som jeg har hentet inspiration fra.
v.h.
Jakob
|