[thelist] Some more simple JavaScript
Chris Kavanagh
chris at logorocks.com
Fri Dec 3 11:18:20 CST 2004
Dear list,
I tried to Google for this but it didn't work out. In this form I have
a selectable list that contains all the months, like so:
<select size="1" name="Month">
<option value="01">Jan</option>
<option value="02">Feb</option>
<option value="03">Mar</option>
<option value="04">Apr</option>
<option value="05">May</option>
<option value="06">Jun</option>
<option value="07">Jul</option>
<option value="08">Aug</option>
<option value="09">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
I'd like the current month to be initially selected, and I need to use
JavaScript to do it. I managed to figure out how to get the current
month by virtue of some JavaScript:
<SCRIPT language="JavaScript">
var now = new Date();
var thisYear = now.getYear();
var thisMonth = now.getMonth();
var thisHour = now.getHours();
var thisMinute = now.getMinutes();
</SCRIPT>
But where do I go from here? I guess I need to put something like this
in each <option> tag:
if thisYear = 1, then "selected"
Is this doable? Sorry I'm such a Java noob. It's all kinda alien to
me, but I am trying.
Thanks!
CK.
More information about the thelist
mailing list