You could do something like this in javascript
:
Code:
function DropDown(targetName)
{
var dropDownInst = this;
this.target = document.getElementById(targetName);
if(targetname == null || this.target == null)
return;
// better to add some sort of exception handling here
// Create prefix array
this.prefixes = ["prefix1", "prefix2", "prefix3"];
// Create DOM select object
var prefixSelect = document.createElement("select");
this.addOptions(prefixSelect, prefixes);
// This is where we handle adding the item
prefixSelect.onchange = function(e){ dropDownInst.addItem(this); };
}
DropDown.prototype.addOptions = function(iSelect, iArray)
{
for(var i=0; i<iArray.length; i++)
{
var option = document.createElement("option");
option.value = iArray[i];
option.text = iArray[i];
iSelect.options.add(option);
}
}
DropDown.prototype.addItem(iSelect)
{
var selectedValue = iSelect.options[iSelect.selectedIndex];
switch(selectedValue)
{
case "desiredPrefix1":
// Add code here to create a new select and append it to the target
break;
case "desiredPrefix2":
// Add code here to create a new select and append it to the target
break;
case "desiredPrefix3":
// Add code here to create a new select and append it to the target
break;
default:
alert("An invalid selection occurred!");
}
}