![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 13
Rep Power: 0
![]() |
How do i replace this Javascript variable with 'JAN', 'FEB', 'MAR' etc...
depending on what number the variable is e.g. if it is 06 then change to JUN example values are 01 02 03 04 05 06 07 etc..... slice_mm |
|
|
|
|
|
#2 |
|
Programmer
|
I would create a text array of the month codes:
var aMonths = new Array(12) { "JAN, "FEB", ..., "DEC" };I doubt if that syntax works in javascript, but you should get the idea. Then, to assign it, simply use something like: slice_mm = aMonths[chosenMonth - 1]; Where chosenMonth is the numeric representation of the day, such as 6 for June. Another way would be: switch(chosenMonth) {
case 1:
slice_mm = "JAN";
break;
case 2:
slice_mm = "FEB";
break;
...
case 12:
slice_mm = "DEC";
break;
}But I prefer the first approach, personally.
__________________
kirkl_uk Last edited by kirkl_uk; Jun 7th, 2005 at 9:55 AM. |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
kirkl_uk is right, FYI the exact syntax for creating the array is:
var months=new Array("Jan","Feb", ...,"Dec");cheers
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|