I would like to use JavaScript to have the current month selected in a dropdown list created in C#. The dropdown list has the twelve months as items. The name of the ddl is cmbMonth. It needs to show the current month when another dropdown list (cmbSearch) changes. Here is the C# code that works:
if (cmbSearch.SelectedIndex == 1)
{
cmbMonth.ClearSelection();
cmbMonth.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;
}
Now I am attempting to do the same thing on the client side using JavaScript in the html section.
It will look something like this:
if (window.document.form1.cmbSearch.selectedIndex == 1)
{
(code for cmbMonth goes here)
}
Any suggestions? Thanks.
if (cmbSearch.SelectedIndex == 1)
{
cmbMonth.ClearSelection();
cmbMonth.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;
}
Now I am attempting to do the same thing on the client side using JavaScript in the html section.
It will look something like this:
if (window.document.form1.cmbSearch.selectedIndex == 1)
{
(code for cmbMonth goes here)
}
Any suggestions? Thanks.