/*Header Begin

$Author: Hem.balla $

$Workfile: SelectBoxes.js $

$Modtime: 4/26/06 10:51a $

$Revision: 6 $

$NoKeywords: $

Change History: Put the issue ID and your description of the changes here
Defect# 6644
added this line 'selectObj.selectedIndex = 0' on the top to return to 0 if there was no match.
Header Ends*/

/* Validates the index number of the selected object, determined by option text.
 * Accepts a list of one to many form elements as parameters.
 */

function SetSelectByText(selectObj, inValue)
{
	//added the next line to return to 0 if there was no match.
	selectObj.selectedIndex = 0;
	
	for (i = 0; i < selectObj.options.length; i++)
	{
		if (selectObj.options[i].text == inValue)
		{
			selectObj.selectedIndex = i;
			break;
		}
	}
}

/* Validates the index number of the selected object, determined by option value. 
 * Ignores upper/lower case.
 * Accepts a list of one to many form elements as parameters.
 */
function SetSelectByValueNoCase(selectObj, inValue)
{
	//added the next line to return to 0 if there was no match.
	selectObj.selectedIndex = 0;
	
	for (i = 0; i < selectObj.options.length; i++)
	{
		var curVal = selectObj.options[i].value.toLowerCase();
		if (curVal == inValue.toLowerCase())
		{
			selectObj.selectedIndex = i;
			break;
		}
	}
}

/* Validates the index number of the selected object, determined by option value. 
 * Accepts a list of one to many form elements as parameters.
 */

function SetSelectByValue(selectObj, inValue)



{
	if(!selectObj)
		return true;
	if(!selectObj.selectedIndex)
		//return true;
		
    //added the next line to return to 0 if there was no match.
	
	selectObj.selectedIndex = 0;
	
	for (i = 0; i < selectObj.options.length; i++)
	{
		if (selectObj.options[i].value == inValue)
		{
			selectObj.selectedIndex = i;
			break;
		}
	}
}

/* Validates the index number of the selected object, determined by option value. 
 * Accepts a list of one to many form elements as parameters.
 */

function SetMultiSelectByValue(selectObj, inValue)
{
	for (i = 0; i < selectObj.options.length; i++)
	{
		if (selectObj.options[i].value == inValue)
		{
			selectObj.options[i].selected = true;
			break;
		}
	}
}
