473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date dropdown not functioning

I have a form on my asp page with 3 dropdowns, day, month & year, but
for some reason, the day dropdown is displaying the 25th twice, instead
of 26th, then 27th ?
I have this script in the <headof my asp page:

_______________ ______

<script type="text/javascript">

var
monthtext=['Jan','Feb','Ma r','Apr','May', 'Jun','Jul','Au g','Sept','Oct' ,'Nov','Dec'];

function populatedropdow n(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=docume nt.getElementBy Id(dayfield)
var monthfield=docu ment.getElement ById(monthfield )
var yearfield=docum ent.getElementB yId(yearfield)
for (var i=0; i<31; i++)
dayfield.option s[i]=new Option(i+1, i+1)
dayfield.option s[today.getDate()]=new Option(today.ge tDate(),
today.getDate() , true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.opti ons[m]=new Option(monthtex t[m], monthtext[m])
monthfield.opti ons[today.getMonth( )]=new
Option(monthtex t[today.getMonth( )], monthtext[today.getMonth( )], true,
true) //select today's month
var thisyear=today. getFullYear()
for (var y=0; y<20; y++){
yearfield.optio ns[y]=new Option(thisyear , thisyear)
thisyear+=1
}
yearfield.optio ns[0]=new Option(today.ge tFullYear(),
today.getFullYe ar(), true, true) //select today's year
}

</script>

_______________ _______________ _______
I have this script in the Body of my asp page:

<script type="text/javascript">

//populatedropdow n(id_of_day_sel ect, id_of_month_sel ect,
id_of_year_sele ct)
window.onload=f unction(){
populatedropdow n("daydropdown" , "monthdropdown" , "yeardropdo wn")
}
</script>

_______________ _______________ ________

I have this code in a form on my asp page:

<select id="daydropdown ">
</select>
<select id="monthdropdo wn">
</select>
<select id="yeardropdow n">
</select>
_______________ _______________ __________

PROBLEM: For some reason, instead of the daydropdown showing

24
25
26
27
28

it is displaying

24
25
26
26
28

Why is it not displaying the 27th day to select, i.e. tomorrow

Appreciate any help you can offer me

Thanks

David

Oct 26 '06 #1
6 1605
David wrote:
I have a form on my asp page with 3 dropdowns, day, month & year, but
for some reason, the day dropdown is displaying the 25th twice, instead
of 26th, then 27th ?
I have this script in the <headof my asp page:

_______________ ______

<script type="text/javascript">

var
monthtext=['Jan','Feb','Ma r','Apr','May', 'Jun','Jul','Au g','Sept','Oct' ,'Nov','Dec'];
>
function populatedropdow n(dayfield, monthfield, yearfield){
var today=new Date()
var dayfield=docume nt.getElementBy Id(dayfield)
var monthfield=docu ment.getElement ById(monthfield )
var yearfield=docum ent.getElementB yId(yearfield)
for (var i=0; i<31; i++)
dayfield.option s[i]=new Option(i+1, i+1)
dayfield.option s[today.getDate()]=new Option(today.ge tDate(),
Here you add today again to the options.
I think you wanted to select it instead of adding it again. :-)
I expect the same happens to year and month.

Regards,
Erwin Moller
today.getDate() , true, true) //select today's day
for (var m=0; m<12; m++)
monthfield.opti ons[m]=new Option(monthtex t[m], monthtext[m])
monthfield.opti ons[today.getMonth( )]=new
Option(monthtex t[today.getMonth( )], monthtext[today.getMonth( )], true,
true) //select today's month
var thisyear=today. getFullYear()
for (var y=0; y<20; y++){
yearfield.optio ns[y]=new Option(thisyear , thisyear)
thisyear+=1
}
yearfield.optio ns[0]=new Option(today.ge tFullYear(),
today.getFullYe ar(), true, true) //select today's year
}

</script>

_______________ _______________ _______
I have this script in the Body of my asp page:

<script type="text/javascript">

//populatedropdow n(id_of_day_sel ect, id_of_month_sel ect,
id_of_year_sele ct)
window.onload=f unction(){
populatedropdow n("daydropdown" , "monthdropdown" , "yeardropdo wn")
}
</script>

_______________ _______________ ________

I have this code in a form on my asp page:

<select id="daydropdown ">
</select>
<select id="monthdropdo wn">
</select>
<select id="yeardropdow n">
</select>
_______________ _______________ __________

PROBLEM: For some reason, instead of the daydropdown showing

24
25
26
27
28

it is displaying

24
25
26
26
28

Why is it not displaying the 27th day to select, i.e. tomorrow

Appreciate any help you can offer me

Thanks

David
Oct 26 '06 #2
Thanks for helping Erwin,

Not being a Javascript wiz, what do I need to do to correct this ?

Thanks so much

David

Oct 26 '06 #3
David wrote:
Thanks for helping Erwin,

Not being a Javascript wiz, what do I need to do to correct this ?

Thanks so much

David
Hi David,

Just add them all, like you did, but remove the new Option for the one you
want to select (today).
Now make some aspcode that checks if the option you are adding is the one
you want to select.

Extend the syntax for a new option like this:
new Option("text", value, defaultselected , selected)

replace them with sensible values, in your case you want to write true for
the defaultselected .

Good luck,
Erwin
Oct 26 '06 #4

Erwin,

I 've had a good look but JavaScript is like dutch to me, I cannot seem
to grasp it :-(
I got this code from the web and I am trying really hard to understand
it .... maybe someday huh !

I can kind of see what you are saying, but cannot fathom how to adjust
the code.

Oh well

Thanks

Oct 26 '06 #5
In message <11************ **********@m73g 2000cwd.googleg roups.com>, Thu,
26 Oct 2006 06:57:56, David <da*********@sc ene-double.co.ukwri tes
>I have a form on my asp page with 3 dropdowns, day, month & year,
At first glance, it looks as if your code allows 31 days for every
month.

See <URL:http://www.merlyn.demo n.co.uk/js-date6.htm#YMD>, but then read
from the top of the page.

It's a good idea to read the newsgroup and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
<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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 26 '06 #6
David wrote:
>
Erwin,

I 've had a good look but JavaScript is like dutch to me, I cannot seem
to grasp it :-(
I got this code from the web and I am trying really hard to understand
it .... maybe someday huh !

I can kind of see what you are saying, but cannot fathom how to adjust
the code.

Oh well

Thanks
Hi David,

JavaScript is like Dutch to you?
You are asking the wrong person for help then, since I AM dutch. :P

Anyway, follow Stockton's advise and read the FAQ. It might help you
understand the issue.

Regards,
Erwin Moller
Oct 30 '06 #7

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

Similar topics

10
8038
by: Bob Bedford | last post by:
I've two input fields in wich the user enter dates. I've put something like "enter date here (dd/mm/yyyy) but most of the user don't enter date in correct format. So I'd like to be able to get any format coming from user as I must put those dates in a MySQL database: some format: (non-US format, so day/month/year) 1/9/2004 1/09/2004 01/9/2004
4
3861
by: James W. Hall Sr. | last post by:
I am filling a dropdown listbox in ASP.NET. The display value is a date field from SQL Server. When I bind the data to the dropdown listbox the time appears in with the data (12:00 am). In the database it appear 12/31/2003. It appears in the control as 12/31/2003 12:00 am. I am trying to format the field in the select statement with no luck. Can anyone help me? James W. Hall Sr.
0
1494
by: Brian Henry | last post by:
Is there anyway to get bold dates to show up on the drop down month calendar on the date time picker? I need a way to show that something occured on a date on the dropdown, and I can't find a boldeddates array like the monthcalendar has for the dropdown... Is there anyway to access the month calendar in the date time picker dropdown and add bolded dates to it? thanks
0
1405
by: Kitten | last post by:
I'm maintaining a site which has a page to show information by the date. It has 3 dropdown boxes - day, month and year. Day is sorted already. The year must only show this year and last year, which is also sorted. Now we come to the tricky part - the month dropdown box must show the months up to this month when this year is selected and from this month to the end of the year if last year is selected. It must be completely dynamic and client...
3
1934
by: rn5a | last post by:
A MS-Access DB table has 2 columns - StartTime & EndTime. Though the data type of both the columns are Date/Time, the records under these 2 columns stores ONLY the TIME part & NOT the DATE part (for e.g. 7:00:00 AM, 2:00:00 PM, 8:35:00 PM etc.). A Form in a ASP page has 3 dropdown lists. The 1st one is to select an hour option, the 2nd one to select a minute option (this dropdown list has only 4 options - 00, 15, 30, 45). The 3rd...
6
2025
by: JKoyis | last post by:
Using Access 2002: I'm having trouble getting the date constants to work right. I'm trying to write code to find the most recent date when a student had a health checkup, compare this with the current date, and output their name if it was too long ago. However the constants for getting the current date don't seem to be functioning. The code is in a form_load event. To test the date stuff I put the following line of code right at the start...
3
1846
by: natalievl | last post by:
Hi, I have a Drop Down List that is being populated by a sql server database with the following query... sqlSchedule = ("SELECT cast(DATE_FROM as smalldatetime) AS DATE from EVENTS WHERE ITEMID = '" + txtid + "'"); The DropDown is populated with '30/09/2007 12:00:00 AM' Can someone please tell me how to change the date format in the dropdown to 30/09/2007.
7
2298
by: tabm2004 | last post by:
I have an ASP main page with date fields dropdown like From date Date .. Month .....Year To date Date.. Month..... Year whenever i open mainpage.asp in the browser, i am needed to select the To & From dates. Instead of that i want the system date should be generated automatically in the dropdown boxes. Plz advice the code for this.
7
1642
by: plumba | last post by:
Hiya all. I have a form which the user selects a date from a javascript style calendar, it puts the date into a field in the format dd/mm/yyyy. I want the form to compare this user selected date to a date which it will work out, which is today's date pluys 7 days. The reason is, the field is a 'Required by' field on a form and I dont want the user to enter a date in the past or one which is less than 7 days from today. So it will...
0
8675
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
8604
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,...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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
8862
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
6521
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
4370
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.