473,598 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple calendar - help please

Hi,
I've got 3 input HTML (dropdown lists) on my page. One for selecting a
Month, one for the day, one for the year. Very simple...

My problem is that I'd like to update the Days one according to what
month was selected (31,30 or 28 days). I should use a simple javascript
to populate the input boxes, but I'm a bit new to javascript.

Please can you help me ?

May 20 '06 #1
11 1681
wrote on 20 mei 2006 in comp.lang.javas cript:
I've got 3 input HTML (dropdown lists) on my page. One for selecting a
Month, one for the day, one for the year. Very simple...

My problem is that I'd like to update the Days one according to what
month was selected (31,30 or 28 days). I should use a simple javascript
to populate the input boxes, but I'm a bit new to javascript.
Why do you think it is simple?
What if the user decides to set the daynumber first?
What about leap years, if the year is not selected first?
Please can you help me ?


I don't think someone here will write your code.
Try it yourself and show where you get a problem.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 20 '06 #2
I don't know how to change the options of the select (the list of
items) from a javascript. I'm just asking for that bit of code. I've
already tried myself...I wouldn't post otherwise.

May 20 '06 #3
wrote on 20 mei 2006 in comp.lang.javas cript:
I don't know how to change the options of the select (the list of
items) from a javascript. I'm just asking for that bit of code. I've
already tried myself...I wouldn't post otherwise.


What are you talking about? This is usenet, so:

Please quote what you are replying to. If you want to post a followup via
groups.google.c om, don't use the "Reply" link at the bottom of the article.
Click on "show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
<http://www.safalra.com/special/googlegroupsrep ly/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 20 '06 #4
Evertjan. said the following on 5/20/2006 7:31 AM:
wrote on 20 mei 2006 in comp.lang.javas cript:
I've got 3 input HTML (dropdown lists) on my page. One for selecting a
Month, one for the day, one for the year. Very simple...

My problem is that I'd like to update the Days one according to what
month was selected (31,30 or 28 days). I should use a simple javascript
to populate the input boxes, but I'm a bit new to javascript.
Why do you think it is simple?


Because it is simple.
What if the user decides to set the daynumber first?
Then you change the days after they change the month.
What about leap years, if the year is not selected first?


Then you deal with it when it happens.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 20 '06 #5
Randy Webb <Hi************ @aol.com> writes:
What about leap years, if the year is not selected first?


Then you deal with it when it happens.


But how will you know it happened if you changed the daynumber when
the month was set?

The coding will be simple, but deciding what should happen when isn't :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
May 21 '06 #6
Lasse Reichstein Nielsen said the following on 5/20/2006 1:51 PM:
Randy Webb <Hi************ @aol.com> writes:
What about leap years, if the year is not selected first? Then you deal with it when it happens.


But how will you know it happened if you changed the daynumber when
the month was set?


When a select gets change, you reset any select after that. It won't
take people long to figure out to fill them out in the order they appear :)

Rather annoying but almost fool proof.
The coding will be simple, but deciding what should happen when isn't :)


Actually, deciding what to do is easier than coding it.

Year changes - reset month/days select lists.
Month changes - reset days select list.
Day of Month changes - do nothing.

Then, if they skip the process then they get to start over.

This is all purely academic to me though, I despise select lists for
entering a date.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 21 '06 #7
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Sat, 20
May 2006 11:31:54 remote, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted :
wrote on 20 mei 2006 in comp.lang.javas cript:
That'll upset the Obnoxious One - not only is it longer than he likes,
but it does not identify the perpetrator!
I've got 3 input HTML (dropdown lists) on my page. One for selecting a
Month, one for the day, one for the year. Very simple...

My problem is that I'd like to update the Days one according to what
month was selected (31,30 or 28 days). I should use a simple javascript
to populate the input boxes, but I'm a bit new to javascript.
Months in the Gregorian calendar can also have 29 days.

Why do you think it is simple?
What if the user decides to set the daynumber first?
What about leap years, if the year is not selected first?


Well, I'd expect that from an FFF user, but not from one dwelling where
EN 28601 is respected! Put the fields in the proper order Y M D, and it
will be natural to select them in that order; there will then be no
problem, even if the fields are initialised to show a short month. And
if the preset is 2000-01-01 (or Jan 1 of any other leap year) then it
seems likely that one can enter a valid date in any sequence of three or
fewer choices.
Please can you help me ?


I don't think someone here will write your code.


?

Those who have read the newsgroup FAQ, frequently cited here, should
have been able to find extant code for the purpose described. A search
for 'javascript date and time', in conjunction with 'drop-down', should
also have found my js-date6.htm, which also has a selector for Year-
Week-Day, suitable for places where all weeks have seven days.

However, I find entering the date as a string matching \d+\D+\d+\D+\d+
to be appreciably quicker, and validation is easy enough for FAQ-users.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
May 21 '06 #8
Dr John Stockton wrote on 20 mei 2006 in comp.lang.javas cript:
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Sat,
20 May 2006 11:31:54 remote, seen in news:comp.lang. javascript,
Evertjan. <ex************ **@interxnl.net > posted :
wrote on 20 mei 2006 in comp.lang.javas cript:
That'll upset the Obnoxious One - not only is it longer than he likes,
but it does not identify the perpetrator!
I've got 3 input HTML (dropdown lists) on my page. One for selecting
a Month, one for the day, one for the year. Very simple...

My problem is that I'd like to update the Days one according to what
month was selected (31,30 or 28 days). I should use a simple
javascript to populate the input boxes, but I'm a bit new to
javascript.
Months in the Gregorian calendar can also have 29 days.

Why do you think it is simple?
What if the user decides to set the daynumber first?
What about leap years, if the year is not selected first?


Well, I'd expect that from an FFF user, but not from one dwelling
where EN 28601 is respected! Put the fields in the proper order Y M
D, and it will be natural to select them in that order;


The OP specified [more or less] m d y order
there will
then be no problem, even if the fields are initialised to show a short
month. And if the preset is 2000-01-01 (or Jan 1 of any other leap
year) then it seems likely that one can enter a valid date in any
sequence of three or fewer choices.
Please can you help me ?
I don't think someone here will write your code.


?

Those who have read the newsgroup FAQ, frequently cited here, should
have been able to find extant code for the purpose described.


That is the same thing, I don't think we should encourage explaining how
to find ready code on the web, as it discourages IMHO programming skil
development and those codes are often years-and-years old.
A
search for 'javascript date and time', in conjunction with
'drop-down', should also have found my js-date6.htm, which also has a
selector for Year- Week-Day, suitable for places where all weeks have
seven days.

However, I find entering the date as a string matching \d+\D+\d+\D+\d+
to be appreciably quicker, and validation is easy enough for
FAQ-users.


Indeed.

A choice of both text and popup calendar is my favored one.

One has to decide the localisation order first:

dmy or mdy for local applications

ymd for the international or technical inclined.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 21 '06 #9
I wanted to use text combined with a popup calendar... But my boss
doesn't want, he wants to stick with the dropdowns...
Anyway, here's a sample of how I finally did it:

<html>
<head>
<title>date</title>
<script type=text/javascript language=javasc ript>
function verifierjours() {
var idx=document.no mduformulaire.m ois.selectedInd ex;
if (idx==1) //Si on choisit février
document.nomduf ormulaire.jours .length=29;
else if (idx==3||idx==5 ||idx==8||idx== 10) // si on choisit avril
ou juin ou septembre ou novembre
{ document.nomduf ormulaire.jours .length=30;
document.nomduf ormulaire.jours .options[29].text='30';
}
else { // si on choisit les autes mois
document.nomduf ormulaire.jours .length=31;
document.nomduf ormulaire.jours .options[29].text='30';
document.nomduf ormulaire.jours .options[30].text='31';
}
}
</script>
</head>
<body>
<form name=nomduformu laire>
<select name=mois onchange=verifi erjours()>

<option>janvier </option><option> fevrier</option><option> mars</option><option> avril</option>

<option>mai</option><option> juin</option><option> juillet</option><option> aout</option>

<option>septemb re</option><option> octobre</option><option> novembre</option><option> decembre</option>
</select>
<select name=jours>

<option>01</option><option> 02</option><option> 03</option><option> 04</option><option> 05</option>

<option>06</option><option> 07</option><option> 08</option><option> 09</option><option> 10</option>

<option>11</option><option> 12</option><option> 13</option><option> 14</option><option> 15</option>

<option>16</option><option> 17</option><option> 18</option><option> 19</option><option> 20</option>

<option>21</option><option> 22</option><option> 23</option><option> 24</option><option> 25</option>

<option>26</option><option> 27</option><option> 28</option><option> 29</option><option> 30</option><option> 31</option>
</select>
</form>
</body>
</html>

May 21 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
10067
by: Szar | last post by:
JS noob. I've seen plenty of browser detection scripts but they all seem to be slightly different and don't really fit my needs. I have various places where if the browser is IE I'd like to display else . For example, if a browser is IE I want to use this CSS file otherwise use a different one and if it's IE make this cell x pixels high else make it y pixels high. I'm sure this is easy, please excuse my stupidity. Steve.
16
3043
by: DFS | last post by:
If you're listening, I want the middle of the calendar (showing 1 month) to open below the cursor position. It currently opens just to the right and below the cursor position. I hunted through the code, but can't determine what to alter. Very nice piece of work, by the way. Thanks
2
1897
by: serge calderara | last post by:
Dear all, I have a webform with a calendar control on it. When loaded the calendar is set to the current date. Depending on a criteria from a database field, calendar day cell appears with red background color for the selected month. This is done by using the Calendar_DayRender event. This works fine What I need to do next is that if my user click on either the NextMonth or PrevMonth, I should get the same behaviour for day cells...
1
2998
by: xian2 | last post by:
Hi, I wanted to create a calendar in Access that would call on data stored within tables in the database (dates in forms) and would show it visually on a calendar when the calendar was opened. I was told about calendar control fundtion and created a calendar in a form but cannot work out how to call on the data within the tables so it appears as an entry in the calendar when the calendar is opened. Please can you give me some advice on...
14
2238
by: magmike | last post by:
Can I do anything with the calendar buttons? I want to display a number on the buttons. I'm using the calendar control on a form that sets a call back date and time. The user can click on the calendar if they wish to set the date in the date field. It also serves the purpose of using a calendar. Also on that form, I have a subform that shows a query which shows the count of call backs set for each date. I would like to be able to...
4
3311
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
1
3676
by: rjlorenzo | last post by:
Good Day, Need your help guys, right now i have a text box where they enter the date with format mm/dd/yyy. Instead mo this i just wnat to put a pop up calendar. when the user click the "Date From" then the pop up calendar will appear and after the user select the date, on the text box it will show the date. Please help me i just need a simple calendar. thank you in advance.
1
4892
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the events when click on that date that perticular event displyed in a text box.But my requirement is to when click on that date that related event displyed in same td row not the text box. and also i add the events to that calendar.plz advice how to...
0
7987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8050
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8264
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3897
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2412
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.