<html>
<head>
<title></title>
<SCRIPT type="text/javaScript">
var frmMode;
var arrOptions = new Array();
arrOptions[0] = "Option1";
arrOptions[1] = "Option2";
arrOptions[2] = "Option3";
arrOptions[3] = "Option4";
arrOptions[4] = "Option5";
function buildSelectList() // Generates the Options list box from the arrOptions array.
{
arrOptions.sort(); //Sort the array alphabetically.
var Options='<select name="SelectList" id="SelectList" size="1"><option value="Select">Select Option</option>';
for (var loop = 0;loop<arrOptions.length; loop++)
Options = Options + '<option value="' + loop + '">' + arrOptions[loop] + '</option>';
Options = Options + '</select>';
OptionList.style.display = 'none';
OptionList.innerHTML=Options;
OptionList.style.display = 'inline';
}
function btncontrol(which) // Process to follow for each button available on screen.
{
// First, hide and show appropriate boxes on screen.
if (which == "Add" || which == "Edit")
{
var tmpindex = document.getElementById('SelectList').selectedIndex;
if (tmpindex <= 0 && which == "Edit")
{
alert("You must first select an Option");
}
else
{
document.getElementById('B1').disabled=true;
document.getElementById('B2').disabled=true;
document.getElementById('B3').disabled=true;
showhide('OptionEdit','visible');
document.getElementById('Title').focus();
frmMode=which;
addeditvalues();
}
}
if (which == "Cancel" || which == "Save")
{
showhide('OptionEdit','hidden');
document.getElementById('B1').disabled=false;
document.getElementById('B2').disabled=false;
document.getElementById('B3').disabled=false;
}
if (which == "Delete") // Handle additions or deletions
{
var tmpindex = document.getElementById('SelectList').selectedIndex;
if (tmpindex <= 0)
{
alert("You must first select an Option");
}
else
{
var Optionindex = document.getElementById('SelectList').selectedIndex-1;
var mymsg = "Delete this entry?";
var conf=confirm_action(mymsg);
if (conf == true)
{
frmMode=which;
updateOptions();
buildSelectList();
}
}
}
if (which == "Save" && frmMode == 'Edit')
{
updateOptions(); // Insert Option into the arrOptions array
buildSelectList(); // Rebuild the Option listbox
}
if (which == "Save" && frmMode == 'Add')
{
updateOptions(); // Insert names into the arrOptions array
buildSelectList(); // Rebuild the names listbox
}
}
function addeditvalues() //Fills in values in the OptionEdit window. Blank if adding new or actual values if editing.
{
if (frmMode == "Add" || document.getElementById('SelectList').selectedIndex == 0)
document.getElementById('Title').value="";
if (frmMode == "Edit" && document.getElementById('SelectList').selectedIndex != 0)
{
var tmpindex = document.getElementById('SelectList').selectedIndex-1;
document.getElementById('Title').value=arrOptions[tmpindex];
}
}
function updateOptions() //Updates array with edited or newly added option.
{
var tmpindex = document.getElementById('SelectList').selectedIndex-1;
if (frmMode == "Add")
{
var arrtmp = arrOptions.length;
arrOptions[arrtmp] = document.getElementById('Title').value;
}
if (frmMode == "Edit")
arrOptions[tmpindex] = document.getElementById('Title').value;
if (frmMode == "Delete" && tmpindex >=0)
arrOptions.splice(tmpindex, 1);
}
function showhide(divname,status) // change visibility of divname to that passed in status
{
document.getElementById(divname).style.visibility = status;
}
function confirm_action(mymsg)
{
var tmpindex = document.getElementById('SelectList').selectedIndex-1;
var tmpname = arrOptions[tmpindex];
if (confirm(mymsg)==true)
{
return true;
}
else
{
return false;
}
}
</script>
</head>
<body bgcolor="#7AA1E6" onload="buildSelectList();">
<form name="Event" action="">
<div align="center">
<table border="0" width="400" cellspacing="0" cellpadding="0" bgcolor="#D6DFF7">
<tr>
<td width="391" colspan="6" style="border-left: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128); border-top: 2px solid rgb(192,192,192)"> </td>
</tr>
<tr>
<td width="116" style="border-left: 2px solid rgb(192,192,192)"> </td>
<td width="275" colspan="5" style="border-right: 2px solid rgb(128,128,128)">
<div id="OptionList" align="center"></div></td>
</tr>
<tr>
<td width="116" height="10" style="border-left: 2px solid rgb(192,192,192)"> </td>
<td width="45" height="10" style="border-left: 2px solid rgb(192,192,192)"></td>
<td width="60" height="10" style="border-left: 2px solid rgb(192,192,192)"></td>
<td width="65" colspan="2" height="10" style="border-left: 2px solid rgb(192,192,192)"></td>
<td width="105" height="10" style="border-right: 2px solid rgb(128,128,128)"> </td>
</tr>
<tr>
<td width="116" style="border-left: 2px solid rgb(192,192,192)"> </td>
<td width="45"><p align="left"><input type="button" value="Add" name="B1"
id="B1" onclick="btncontrol(this.value)"></td>
<td width="60"><p align="center"><input type="button" value="Edit" name="B2"
id="B2" onclick="btncontrol(this.value)"></td>
<td width="65" colspan="2"><p align="right"><input type="button" value="Delete" name="B3"
id="B3" onclick="btncontrol(this.value)"></td>
<td width="105" style="border-right: 2px solid rgb(128,128,128)"> </td>
</tr>
<tr>
<td width="116" height="25" style="border-left: 2px solid rgb(192,192,192)"> </td>
<td width="45" height="25" style="border-left: 2px solid rgb(192,192,192)"></td>
<td width="60" height="25" style="border-left: 2px solid rgb(192,192,192)"></td>
<td width="65" colspan="2" height="25" style="border-left: 2px solid rgb(192,192,192)"></td>
<td width="105" height="25" style="border-right: 2px solid rgb(128,128,128)"> </td>
</tr>
<tr>
<td width="230" colspan="3"
style="border-left: 2px solid rgb(192,192,192); border-bottom: 2px solid rgb(128,128,128)"> </td>
<td width="35" style="border-bottom: 2px solid rgb(128,128,128)"> </td>
<td width="135" colspan="2"
style="border-right: 2px solid rgb(128,128,128); border-bottom: 2px solid rgb(128,128,128)"> </td>
</tr>
</table>
<div id="OptionEdit" Style="visibility: hidden">
<table border="0" cellspacing="0" cellpadding="0" width="600" align="center">
<tr>
<td width="600" height="10" colspan="2" bgcolor="#7AA1E6"></td>
</tr>
<tr>
<td width="600" height="9" colspan="2" bgcolor="#D6DFF7" style="border-left: 2px solid rgb(192,192,192); border-top: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128)"> </td>
</tr>
<tr>
<td width="600" height="7" bgcolor="#D6DFF7" align="center" style="border-left: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128); padding-left: 4px"><strong>Option Title</strong></td>
</tr>
<tr>
<td width="600" bgcolor="#D6DFF7" align="center" style="border-left: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128); padding-left: 4px"><input type="text" name="Title" id="Title" size="30"></td>
</tr>
<tr>
<td width="600" bgcolor="#D6DFF7" height="10" colspan="2" style="border-left: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128)"> </td>
</tr>
<tr>
<td width="600" bgcolor="#D6DFF7" height="3" colspan="2" style="border-left: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128)"><p align="center"><input type="button" value="Save"
name="B7" id="B7" onclick="btncontrol(this.value)"> <input type="button" value="Cancel" name="B8" id="B8" onclick="btncontrol(this.value)"></td>
</tr>
<tr>
<td width="600" height="9" colspan="2" bgcolor="#D6DFF7" style="border-left: 2px solid rgb(192,192,192); border-right: 2px solid rgb(128,128,128); border-bottom: 2px solid rgb(128,128,128)"> </td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>