Entry
how to script which option in a select drop-down should be selected?
Feb 3rd, 2005 04:42
jsWalter, carsten dfgb,
// {{{ selectOption()
// Select a single option
function selectOption ( $objSelect, $intOptionIndex )
{
// If $objFocusList is a string, convert to Object Reference
// Then see if Object Reference exists
if ( ( typeof ( $objSelect ) ) == 'string' )
$objSelect = document.getElementById($objSelect);
// Do we have a list to deal with?
if ( ( $objSelect ) && ( $intOptionIndex >= 0 ) )
{
// Move focus and Select Item
$objSelect.focus();
$objSelect.options[$intOptionIndex].selected = true;
}
};
// }}}
This is part of a larger collection of functions and methods I've been
putting together for years.
Walter