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

Checking Select Option Value Without Form Submital

P: n/a
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date. However I would like to make it so when you choose a year
and a month the appropriate days for that month show (i.e. 28 days if
you chose February 2006). I can easily do this with a loop if I can
find out what month the user has selected, but I can't seem to find a
way to get that value. Is there a simple javascript solution to this
problem?

Feb 5 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a
VK

75******@gmail.com wrote:
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date. However I would like to make it so when you choose a year
and a month the appropriate days for that month show (i.e. 28 days if
you chose February 2006). I can easily do this with a loop if I can
find out what month the user has selected, but I can't seem to find a
way to get that value. Is there a simple javascript solution to this
problem?


<select name="myMonthList"
onchange="setBestDay(this.form, this.selectedIndex)">
<option value="0">January</option>
...
</select>

where in the <head> section you have:

<script type="text/javascript">
function setBestDay(f,m) {
// m corresponds to the selected month
// 0 - January, 11 - December
// do your calculations
// then:
f.myDayList.selectedIndex = myCalculatedIndex;
}
</script>

Feb 5 '06 #2

P: n/a
75******@gmail.com wrote:
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date.


No it bloody isn't! I *hate* having to go through the click, scroll
select 3 times!

Have an input field with flexible validation, and a popup calendar for
those who *must* use their mouse. There are plenty of open source
examples out there.
Feb 5 '06 #3

P: n/a
Don't you want to use a popup calendar?
<75******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date. However I would like to make it so when you choose a year
and a month the appropriate days for that month show (i.e. 28 days if
you chose February 2006). I can easily do this with a loop if I can
find out what month the user has selected, but I can't seem to find a
way to get that value. Is there a simple javascript solution to this
problem?

Feb 5 '06 #4

P: n/a
TheBagbournes wrote:
75******@gmail.com wrote:
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date.

No it bloody isn't! I *hate* having to go through the click, scroll
select 3 times!

Have an input field with flexible validation, and a popup calendar for
those who *must* use their mouse. There are plenty of open source
examples out there.


Complete agreement.
--
Rob
Feb 5 '06 #5

P: n/a
VK wrote:
75******@gmail.com wrote: <snip>
... . However I would like to make it so when you choose a
year and a month the appropriate days for that month show
(i.e. 28 days if you chose February 2006). ...

<snip>
<select name="myMonthList"
onchange="setBestDay(this.form, this.selectedIndex)">
<option value="0">January</option>
...
</select>

where in the <head> section you have:

<script type="text/javascript">
function setBestDay(f,m) {
// m corresponds to the selected month
// 0 - January, 11 - December
// do your calculations
// then:
f.myDayList.selectedIndex = myCalculatedIndex;
}
</script>


Don't be silly, it makes absolutely no sense what so ever to select a
day of the month for the user in response to the user selecting a month
and a year.

Richard.
Feb 6 '06 #6

P: n/a
VK
Anyone reading OP's text in this newsgroup besides me? The spelled task
was to *suggest* a day *based on the selected year and month*. Read it
again... then again... then again... bingo! (or not yet?)

:-)

Feb 6 '06 #7

P: n/a
VK wrote:
Anyone reading OP's text in this newsgroup besides me? The spelled
task was to *suggest* a day *based on the selected year and month*.
Read it again... then again... then again... bingo! (or not yet?)


The OP's specified requirement was to alter the number of days available
for selection as options to correspond with the number of days available
in the selected month in the selected year. It makes no sense at all
'suggest' a day selection based on the selection of a month or a year.
Try reading it yourself, and again try to understand that when your
interpretation of something differs from everyone else's the odds are
that it is you who is wrong.

Richard.

Feb 6 '06 #8

P: n/a
VK wrote:
Anyone reading OP's text in this newsgroup besides me? The spelled
task was to *suggest* a day *based on the selected year and month*.
Read it again... then again... then again... bingo! (or not yet?)


The OP's specified requirement was to alter the number of days available
for selection as options to correspond with the number of days available
in the selected month in the selected year. It makes no sense at all
'suggest' a day selection based on the selection of a month or a year.
Try reading it yourself, and again try to understand that when your
interpretation of something differs from everyone else's the odds are
that it is you who is wrong.

Richard.

Feb 6 '06 #9

P: n/a
JRS: In article <11**********************@f14g2000cwb.googlegroups .com>
, dated Sun, 5 Feb 2006 13:41:01 remote, seen in
news:comp.lang.javascript, VK <sc**********@yahoo.com> posted :

75******@gmail.com wrote:
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date. However I would like to make it so when you choose a year
and a month the appropriate days for that month show (i.e. 28 days if
you chose February 2006). I can easily do this with a loop if I can
find out what month the user has selected, but I can't seem to find a
way to get that value. Is there a simple javascript solution to this
problem?


<select name="myMonthList"
onchange="setBestDay(this.form, this.selectedIndex)">
<option value="0">January</option>
...
</select>

where in the <head> section you have:

<script type="text/javascript">
function setBestDay(f,m) {
// m corresponds to the selected month
// 0 - January, 11 - December
// do your calculations
// then:
f.myDayList.selectedIndex = myCalculatedIndex;
}
</script>


There is much to be said for understanding a question before attempting
to give an answer - you should try it sometime.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Feb 6 '06 #10

P: n/a
JRS: In article <11**********************@o13g2000cwo.googlegroups .com>
, dated Sun, 5 Feb 2006 12:47:13 remote, seen in
news:comp.lang.javascript, 75******@gmail.com posted :
I am allowing a user to selected a date to schedule an event and it
seems like the best way to do this is with drop down menus for Year,
month, date.
It isn't, at least for users of normal intelligence.
However I would like to make it so when you choose a year
and a month the appropriate days for that month show (i.e. 28 days if
you chose February 2006). I can easily do this with a loop if I can
find out what month the user has selected, but I can't seem to find a
way to get that value. Is there a simple javascript solution to this
problem?


I don't know. There is a javascript solution, but I don't know whether
it would be right to call it simple.

Before posting to a newsgroup, one should seek and study its FAQ. That
would have led you not only to code that does just what you ask for, but
also to reasons against using drop-downs for date. See below.

Note that if a page is intended to be usable without javascript, then
the day-of-month element must be loaded with 1..31 by HTML.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 6 '06 #11

P: n/a
JRS: In article <11*********************@z14g2000cwz.googlegroups. com>,
dated Sun, 5 Feb 2006 23:44:31 remote, seen in
news:comp.lang.javascript, VK <sc**********@yahoo.com> posted :
Anyone reading OP's text in this newsgroup besides me? The spelled task
was to *suggest* a day *based on the selected year and month*. Read it
again... then again... then again... bingo! (or not yet?)


We already have discovered that you do not understand programming, and
that you cannot write proper English.

Now we have convincing evidence that you cannot understand (almost)
proper English.

Are there no EFL classes in your area? Could you not start a javascript
newsgroup in a hierarchy for your mother-tongue?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Feb 6 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.