Saturday, December 29, 2007

JavaScript: Check if a HTML list contains an element with specified value

// ***
// Check if a HTML list contains an element with specified value
// ***
function optionExists(lst, val)
{
response = false;
for (var i=0; i < lst.length; i++)
{
if (lst.options[i].value==val)
{
response = true;
break;
}
}
return response;
}

No comments:

Post a Comment

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.