Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date in javascript (not show 31 in february ...)

Status
Not open for further replies.

Daft

Programmer
Oct 19, 2000
9
BE
Hi

I must do a form where I ask for the birthday, I do 3 <select> and I want that when I choose february, the 31° are not available ? How can I do that ??

Please Help

Daft
 
set an onchange event on the month select box, and make it call a javascript function that updates (or only checks for the value) for the day
 
Yeah Iza that i know but how can I in javascript 'hide' some number in the day-select ?
 
i would remove the values > 29 if the month is february, add them instead. There might be a smarter solution but i don't see :-(

removing an option
the_name_of_your_lisbox.options.remove(the_index_of_the_item_you_wish_to_remove);

adding an option
var oOption = document.createElement(&quot;OPTION&quot;);
oOption.text=the_text_of_the_item_you_want_to_add;
oOption.value=the_value(index)_of_the_item_you_want_to_add;
the_name_of_your_lisbox.options.add(oOption)
 
You could have an array which holds the number of days for each month, where the index will correspond to the month:

daysArray[0]= days in January etc...

onChange in the month select box add some script which just takes the selected index from the month, and applies it to your array, returning the number of days.You can for loop it put all the values in for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top