/*One of the strange things I discovered is that the target select box (the second one) must have a SIZE of more than 1, or else Netscape and Explorer each develop their own bugs.*/
/*
Object detection
As to this cryptic option in the example above, it is for object detection.
One big problem is that you cannot create or delete options in some browsers. Therefore we have to do some object detection to find out if the browser can handle everything.
This is more difficult than usual because the option object itself is supported by all browsers. What we want to know here is if we can add or remove option objects. The trick is to put one extra option in one select box. A script called onLoad tries to remove this option. If, after that, the option's still there the browser has failed its support detect.
This script performs the detect and gives a variable optionTest. If it's false the browser can't handle dynamic options and you should not execute the scripts.
*/
/**
* Get the value for the currently selected item.
*
* @param
* @return
*/
function select_current_value(item_id)
{
var current_value = "";
if (document.getElementById(item_id) !== null)
{
current_value = document.getElementById(item_id).options[document.getElementById(item_id).selectedIndex].value;
}
return current_value;
}
function select_init(item_id)
{
if (document.getElementById(item_id) !== null)
{
var obj_item = document.getElementById(item_id);
// w/o var, makes it global.
optionTest = true;
lgth = obj_item.options.length - 1;
obj_item.options[lgth] = null;
if (obj_item.options[lgth]) optionTest = false;
}
}
// Make sure browser selects can handle Delete/Insert.
// Put a field at end of test item, then try to delete it.
function select_init2(item_id)
{
if (document.getElementById(item_id) !== null)
{
var obj_item = document.getElementById(item_id);
// w/o var, makes it global.
optionTest = true;
lgth = obj_item.options.length - 1;
obj_item.options[lgth] = null;
if (obj_item.options[lgth]) optionTest = false;
}
}
function select_populate(item_id_from, item_id_to, a_selectData)
{
// Validation Option Addition/Deletion Support.
//if (!optionTest) return;
//alert(item_id_from);
// Access DOM Objects.
var obj_from = document.getElementById(item_id_from);
var obj_to = document.getElementById(item_id_to);
// Selected Item.
var from_value = obj_from.options[obj_from.selectedIndex].value;
//alert(from_value);
if (!from_value) return;
var data_id = null;
// Find this Item in the Search Array.
for(i=0;i';
document.getElementById(item_id).focus();
return true;
}
}
return false;
}
/**
* Populates a Select Box with an Array.
*
* @author Higher Mind Productions.
* @variable item_id - id of the select box we are removing.
* @variable a_selectData - Array of data the we are adding.
* @variable b_matchSelected - Select the item with the similar indexin the new data.
*/
function select_refill(item_id, a_selectData, b_matchSelected)
{
// Access DOM Object.
var obj_select = document.getElementById(item_id);
// Find Selected.
if (b_matchSelected)
{
// var n_selected = obj_select.selectedIndex;
// if (!n_selected || n_selected==null) n_selected=0;
}
// Empty Select Box.
//select_clear(item_id);
// Fill Select Box.
for(i=0;i