By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

month and day of month edit fields

P: n/a

I wish to have a month select and next to it a day select.

Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?
Feb 19 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Richard

Richard wrote:
I wish to have a month select and next to it a day select.
Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?
Client side programming languages i.e. JavaScript (AJAX)...

HTH; Johannes
Feb 19 '07 #2

P: n/a
On 19 Feb, 12:45, Richard <rgr...@gmail.comwrote:
I wish to have a month select and next to it a day select.

Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?
What a negative way of asking!

How about "Is there any way that..."

Anyway, it depends on what you mean by "a previous submit".

3 ways spring to mind of how to do this:

1) Use pure local javascript to populate the day select based on the
selected month. No submit required at all.
2) Use an AJAX type call to let php/javascript populate the day
select.
3) Have the month select automagically submit the form and have it
return a populated day select control.

Of course, you could just use a javascript pop-up calendar.

Feb 19 '07 #3

P: n/a
"Johannes Vogel" <ne********@jvogel.chwrote in message
news:89**************************@news.hispeed.ch. ..
Hi Richard

Richard wrote:
>I wish to have a month select and next to it a day select.
Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?

Client side programming languages i.e. JavaScript (AJAX)...

Fuck Ajax. There's no need to get all ajaxy and "hey look at me I'm so
web2.0" for something as trivial as testing wether february has 28 or 29
days. All other months are constants, they have either 31 or 30 days, then
you just populate the day select with given number of days. What the hell
would you do with ajax?

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Feb 20 '07 #4

P: n/a
Rik
Kimmo Laine <sp**@outolempi.netwrote:
"Johannes Vogel" <ne********@jvogel.chwrote:
>Richard wrote:
>>I wish to have a month select and next to it a day select.
Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?

Client side programming languages i.e. JavaScript (AJAX)...

Fuck Ajax. There's no need to get all ajaxy and "hey look at me I'm so
web2.0" for something as trivial as testing wether february has 28 or 29
days. All other months are constants, they have either 31 or 30 days,
then
you just populate the day select with given number of days. What the hell
would you do with ajax?

Well, if you want to limit the choices in the day after selecting the
month, without a submit in between, certainly some client side code is in
order. However, most people are smart enough to select real dates, and if
someone was to select for instance 31/04, my code usually just assumes
they mean 01/05.
--
Rik Wasmus
Feb 20 '07 #5

P: n/a
Hi Kimmo

Kimmo Laine wrote:
"Johannes Vogel" <ne********@jvogel.chwrote in message
news:89**************************@news.hispeed.ch. ..
>Richard wrote:
>>I wish to have a month select and next to it a day select.
Is there no way at all for the day field to pick up the selected month
without a previous submit on the part of the user?
Client side programming languages i.e. JavaScript (AJAX)...
Fuck Ajax. There's no need to get all ajaxy and "hey look at me I'm so
web2.0" for something as trivial as testing wether february has 28 or 29
days. All other months are constants, they have either 31 or 30 days, then
you just populate the day select with given number of days. What the hell
would you do with ajax?
That's because I wrote i.e. JavaScript. But it's possible with AJAX
mechanism too.

It's not as trivial as you wrote for testing how many days a month has -
and you have to check the date again after sending to the server.
Perhaps with AJAX it's smarter to program.

HTH; Johannes
Feb 20 '07 #6

P: n/a
Captain Paralytic wrote:
1) Use pure local javascript to populate the day select based on the
selected month. No submit required at all.
Better still, initially provide a day select with 31 days, and then
*depopulate* it based on the selected month. That way:

- it's still very usable for non-JS users;
- people can select the day first, then the month, if they wish.
2) Use an AJAX type call to let php/javascript populate the day
select.
As Kimmo said, AJAX is overkill here. Using AJAX, you add an extra
round-trip to the server, break your form in non-AJAX-capable browsers,
all for no real benefit. It's trivially easy to calculate the number of
days in any given month using client-side Javascript. No advantage
whatsoever in having the server do it for you.

(Of course, you will still need to do sanity checks on the server! One
must always do so!)

An alternative would be something like:

<select>
<option>01 Jan
<option>02 Jan
<option>03 Jan
...
<option>30 Dec
<option>31 Dec
</select>

though that adds about 5 kB of data to the page.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Feb 20 '07 #7

P: n/a
On 20 Feb, 14:15, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
Captain Paralytic wrote:
1) Use pure local javascript to populate the day select based on the
selected month. No submit required at all.

Better still, initially provide a day select with 31 days, and then
*depopulate* it based on the selected month. That way:

- it's still very usable for non-JS users;
- people can select the day first, then the month, if they wish.
2) Use an AJAX type call to let php/javascript populate the day
select.

As Kimmo said, AJAX is overkill here. Using AJAX, you add an extra
round-trip to the server, break your form in non-AJAX-capable browsers,
all for no real benefit. It's trivially easy to calculate the number of
days in any given month using client-side Javascript. No advantage
whatsoever in having the server do it for you.
I completely agree with this sentiment.
Remember that my preceeding statement was:
Anyway, it depends on what you mean by "a previous submit".

I would either use javascript to populate the list or a popup
calendar.
However, since the user had mentioned a submit, he may have had a
reason for going to the host, so I offered all the obvious options.
>
(Of course, you will still need to do sanity checks on the server! One
must always do so!)

An alternative would be something like:

<select>
<option>01 Jan
<option>02 Jan
<option>03 Jan
...
<option>30 Dec
<option>31 Dec
</select>

though that adds about 5 kB of data to the page.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

Feb 20 '07 #8

P: n/a
..oO(Johannes Vogel)
>It's not as trivial as you wrote for testing how many days a month has -
All it needs is a test for leap years, which is a very simple algorithm.
>and you have to check the date again after sending to the server.
You _always_ have to check _everything_ on the server. Client-side
validation can be nice to have, but it's completely unreliable.
>Perhaps with AJAX it's smarter to program.
Not in this case. It would require an additional but useless HTTP
request and you still have to validate again on the server.

Micha
Feb 20 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.