I have to develop a search function in javascript such that it will display a message/pop-up window when users does not select an option in dropdownlist. I am using usercontrols in my project. so the dropdownlist's are in .ascx file and my search function will be in .aspx file. Here is the code which I am using:
function Search()
{
var src_status = createObj("bodyuc_drp_Status").value;
var src_program = createObj("bodyuc_drp_program").value;
if(document.getElementById(src_program).value == 0 && document.getElementById(src_client).value == 0)
{
alert("Please select atleast one client or program")
return false;
}
else {
createObj("hdn_search").value = "Search";
return true;
}
}
the value '0' in the if condition is the index of '--select one--' option in the dropdownlist. The above alert message should be displayed when the index is 0 otherwise the user should get the data based on his selection.
This code gives me alert message even if the users select a value other than the 'select one' option. Can anyone tell my why?
really appreciate your help.