Something like:
<html>
<head></head>
<body>
<b>Expect: Jan, Dec</b>
<br />
<script>
// months to test this works!
var testMonthJan='01';
var testMonthDec='12';
// array of month names, numbered 1..12 - zero is empty string
var months = new Array('','Jan','Feb','Mar','Apr','May','Jun','Jul' ,'Aug','Sep','Oct','Nov','Dec');
document.write("--> ");
printMonth(testMonthJan);
document.write(", ");
printMonth(testMonthDec);
// print the name of our month
function printMonth(inp) {
var stripZero = inp.replace(/^0/,""); //strip leading zero
if (stripZero<1 || stripZero>12) {
// check we have a valid month!
document.write("Invalid month given to printMonth: " + inp);
}
else {
// print month name if we do
document.write(months[stripZero]);
}
}
</script>
</body>
</html>
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com