File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes javascript function to return a value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript function to return a value" Watch "javascript function to return a value" New topic

javascript function to return a value

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303

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!

SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
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.

Life called,so here I am.<br />Cheers<br />Niki.:-)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
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 ]
Don't get me started about those stupid light bulbs.
subject: javascript function to return a value
It's not a secret anymore!