Hello,
How can I compact this code?
var the_month_selected;
if (window.document.registration_form.the_month_field.options[1].selected == true)
{
//alert(“It’s January!”);
the_month_selected = “01”
}
else
if (window.document.registration_form.the_month_field.options[2].selected == true)
{
//alert(“It’s February!”);
the_month_selected = “02”
}
else
if (window.document.registration_form.the_month_field.options[3].selected == true)
{
//alert(“It’s March!”);
the_month_selected = “03”
}
else
if (window.document.registration_form.the_month_field.options[4].selected == true)
{
//alert(“It’s April!”);
the_month_selected = “04”
}
else
if (window.document.registration_form.the_month_field.options[5].selected == true)
{
//alert(“It’s May!”);
the_month_selected = “05”
}
else
if (window.document.registration_form.the_month_field.options[6].selected == true)
{
//alert(“It’s June!”);
the_month_selected = “06”
}
else
if (window.document.registration_form.the_month_field.options[7].selected == true)
{
//alert(“It’s July!”);
the_month_selected = “07”
}
else
if (window.document.registration_form.the_month_field.options[8].selected == true)
{
//alert(“It’s August!”);
the_month_selected = “08”
}
else
if (window.document.registration_form.the_month_field.options[9].selected == true)
{
//alert(“It’s September!”);
the_month_selected = “09”
}
else
if (window.document.registration_form.the_month_field.options[10].selected == true)
{
//alert(“It’s October!”);
the_month_selected = “10”
}
else
if (window.document.registration_form.the_month_field.options[11].selected == true)
{
//alert(“It’s November!”);
the_month_selected = “11”
}
else
if (window.document.registration_form.the_month_field.options[12].selected == true)
{
//alert(“It’s December!”);
the_month_selected = “12”
}
Thanks
Lennox