• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript function to return a value

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have a drop down with names of the months.
I want to check the current month from system date/time and highlight the current month in the drop down. How do I do this?

plz help!
 
Niki Nono
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you highlight a single option in a drop-down?
never done that.
anyways you can use the ONchange event to call a function which will do the checks for you.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can construct a Date object, and get its current month, like
var month = new Date().getMonth();
Then you use that to select the month in your menu, like
document.form.month.selectedIndex = month-1;
assuming that your SELECT element is named 'month'.
[ August 31, 2005: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic