I have a drop down box which is working but I want to put it on the same page twice because the document.drop_list.? is hard coded it will not work if I try and use it twice on the same page I have tried sending the id to the javascript but it didn't work. Any Idea How Id do this ?
This is what I have done as of now.
<SCRIPT LANGUAGE="JavaScript">
function fillCategory(){
// this function is used to fill the category list on load
addOption(document.drop_list.Category, "CORK", "CORK", "CORK");
addOption(document.drop_list.Category, "KERRY", "KERRY", "KERRY");
}
function SelectBarnoy(obj){
// ON selection of category this function will work
removeAllOptions(document.drop_list.obj);
addOption(document.drop_list.obj, "", "Barnoy", "");
if(document.drop_list.Category.value == "CORK"){
addOption(document.drop_list.obj,"WEST CARBERY (WEST DIVISION)", "WEST CARBERY (WEST DIVISION)");
}
if(document.drop_list.Category.value == "KERRY"){
addOption(document.drop_list.obj,"ABAB", "ABAB");
addOption(document.drop_list.obj,"KSJDJH", "KSJDJH");
}
}
function SelectParish(){
// ON selection of category this function will work
removeAllOptions(document.drop_list.Parish);
addOption(document.drop_list.Parish, "", "Parish", "");
if(document.drop_list.Category.value == "CORK"){
if(document.drop_list.Barnoy.value == "WEST CARBERY (WEST DIVISION)"){
addOption(document.drop_list.Parish,"KILCROHANE", "KILCROHANE");
addOption(document.drop_list.Parish,"DURRUS", "DURRUS");
addOption(document.drop_list.Parish,"KILMOCOMOGE", "KILMOCOMOGE");
addOption(document.drop_list.Parish,"KILCOE", "KILCOE");
addOption(document.drop_list.Parish,"CAHERAGH", "CAHERAGH");
addOption(document.drop_list.Parish,"SKULL", "SKULL");
addOption(document.drop_list.Parish,"KILMOE", "KILMOE");
}
}
if(document.drop_list.Category.value == "KERRY"){
if(document.drop_list.Barnoy.value == "ABAB"){
addOption(document.drop_list.Parish,"ASDA", "ASDA");
}
if(document.drop_list.Barnoy.value == "KSJDJH"){
addOption(document.drop_list.Parish,"JKDJDF", "JKDJDF");
}
}
}
function SelectTownLand(){
// ON selection of category this function will work
removeAllOptions(document.drop_list.TownLand);
addOption(document.drop_list.TownLand, "", "TownLand", "");
if(document.drop_list.Category.value == "CORK"){
if(document.drop_list.Barnoy.value == "WEST CARBERY (WEST DIVISION)"){
if(document.drop_list.Parish.value == "KILCROHANE"){}
if(document.drop_list.Parish.value == "DURRUS"){}
if(document.drop_list.Parish.value == "KILMOCOMOGE"){}
if(document.drop_list.Parish.value == "KILCOE"){}
if(document.drop_list.Parish.value == "CAHERAGH"){}
if(document.drop_list.Parish.value == "SKULL"){}
if(document.drop_list.Parish.value == "KILMOE"){
addOption(document.drop_list.TownLand,"1", "BALLYRISODE");
addOption(document.drop_list.TownLand,"2", "KILMOE");
addOption(document.drop_list.TownLand,"3", "CAHERAGH");
addOption(document.drop_list.TownLand,"4", "DURRUS");
addOption(document.drop_list.TownLand,"5", "KILCOE");
addOption(document.drop_list.TownLand,"6", "KILCROHANE");
addOption(document.drop_list.TownLand,"7", "KILMOCOMOGE");
addOption(document.drop_list.TownLand,"9", "ASDA");
addOption(document.drop_list.TownLand,"10", "TOOR");
addOption(document.drop_list.TownLand,"11", "DUNLOUGH");
addOption(document.drop_list.TownLand,"12", "GORTBRACK");
addOption(document.drop_list.TownLand,"13", "KNOCKATASSONIG");
addOption(document.drop_list.TownLand,"14", "ALTER");
addOption(document.drop_list.TownLand,"15", "BALTEEN");
addOption(document.drop_list.TownLand,"16", "KEALFADDA")
}
}
}
if(document.drop_list.Category.value == "KERRY"){
if(document.drop_list.Barnoy.value == "ABAB"){
if(document.drop_list.Parish.value == "ASDA"){}
}
if(document.drop_list.Barnoy.value == "KSJDJH"){
if(document.drop_list.Parish.value == "JKDJDF"){}
}
}
}
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);
}
</SCRIPT>
<script type="text/javascript" src="../js/toggleSearch.js"></script>
</head>
<body onload="fillCategory();">
<div id="main">
<form action="" method="POST" id="search">
<fieldset>
<legend>Search</legend>
<p>
<input type="text" size="17" name="town" class="input-text" />
<input type="submit" value="OK" class="input-submit-02" />
<br />
</form>
<p>
<FORM name="drop_list" action="" >
County:<SELECT NAME="Category" onChange="SelectBarnoy(Barnoy);javascript:toggleSearch('Barnoy')" >
<Option value="">Category</option>
</SELECT>
<BR>
Barnoy:<SELECT id="Barnoy" NAME="Barnoy" onChange="SelectParish();javascript:toggleSearch('Parish')" style="display:none;">
<Option value="">Barnoy</option>
</SELECT>
<BR>
Parish:<SELECT id="Parish" NAME="Parish" onChange="SelectTownLand();javascript:toggleSearch('TownLand')" style="display:none;">
<Option value="">Parish</option>
</SELECT>
<BR>
TownLand:<SELECT id="TownLand" NAME="TownLand" style="display:none;">
<Option value="">TownLand</option>
</SELECT>
</FORM>
</p>
</div>
<!-- /search-options -->
</fieldset>
</form>
</div>
</body>
</html>
Any help would be appreciated