Jump to content

[SOLVED] CONVERT JANUARY INTO 01


alvinchua

Recommended Posts

i need HELP !

 

how to convert a month like

 

January in a combo box into a value ===> 01

Febuary in a combo box into a value  ===> 02

 

(this is because i am letting people to select the month as string in a combo box like Jan, Feb, March, bla bla... and later on i need to convert it into numeric to calculate days between two dates )

 

pls advice..

Link to comment
Share on other sites

<script language="javascript">
var month="January";
switch(month) {
case "January":
var month="01";
break;
case "February":
var month="02";
break;
case "March":
var month="03";
break;
case "April":
var month="04";
break;
case "May":
var month="05";
break;
case "June":
var month="06";
break;
case "July":
var month="07";
break;
case "August":
var month="08";
break;
case "September":
var month="09";
break;
case "October":
var month="10";
break;
case "November":
var month="11";
break;
case "December":
var month="12";
break;
}
alert(month); // remove this - demo purposes only
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.