473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Form Select - out of order....

Hi,

I have a form with 2 select objects which are not linked together in
any way. The list exactly the same information.

The code that generates the data is:

_________________________________________

<SCRIPT language='vbscript'>
Sub Window_Onload
Dim TheDate
Dim Count
Dim Options
Dim Options2
TheDate2 = Date + vbThursday - WeekDay(Date)
TheDate = Date + vbTuesday - WeekDay(Date)
If TheDate < Date Then TheDate = TheDate +7
Set Options = Document.all.date.Options
Set Options2 = Document.all.todate.Options

For Count = 1 To 20-1
StrDate = "Tuesday " & Right("0" & Day(TheDate),2) & "/" &
Right("0" & Month(TheDate),2) & "/" & Year(TheDate)
Options.Add Window.Option(StrDate,"from " & StrDate)
Options2.Add Window.Option(StrDate,"to " & StrDate)
TheDate = TheDate + 7

StrDate2 = "Thursday " & Right("0" & Day(TheDate2),2) & "/" &
Right("0" & Month(TheDate2),2) & "/" & Year(TheDate2)
Options.Add Window.Option(StrDate2,"from " & StrDate2)
Options2.Add Window.Option(StrDate2,"to " & StrDate2)
TheDate2 = TheDate2 + 7
Next
End Sub

</script>

______________________________________________

The information is correct, except that every now and again the Tusdays
& Thursdays are wrong way around depending on the current date, i.e.

it should display:

Thursday 03/02/2005
Tuesday 08/02/2005

looping continuously with Tuesdays & Thursdays in the correct date
order.

I seem to get

Tuesday 08/02/2005
Thursday 03/02/2005

How can I correct this code so that no matter what the actual date is,
the data is always in the correct order ?
Appreciate your advice

David.

Jul 23 '05 #1
2 1468
Lee
da***@scene-double.co.uk said:

Hi,

I have a form with 2 select objects which are not linked together in
any way. The list exactly the same information.

The code that generates the data is:

_________________________________________

<SCRIPT language='vbscript'> How can I correct this code so that no matter what the actual date is,
the data is always in the correct order ?
Appreciate your advice


My advice is to ask in a vbscript group, rather than javascript.
Sorry.

Jul 23 '05 #2
JRS: In article <11*********************@l41g2000cwc.googlegroups. com>,
dated Wed, 2 Feb 2005 08:03:35, seen in news:comp.lang.javascript,
da***@scene-double.co.uk posted :
I have a form with 2 select objects which are not linked together in
any way.
The list exactly the same information.
Meaning absent.
The code that generates the data is:

_________________________________________

<SCRIPT language='vbscript'>
Doubly deprecated. Should be <script type="text/javascript"> here
Sub Window_Onload
Dim TheDate
Dim Count
Dim Options
Dim Options2
TheDate2 = Date + vbThursday - WeekDay(Date)
TheDate = Date + vbTuesday - WeekDay(Date)
If TheDate < Date Then TheDate = TheDate +7
Set Options = Document.all.date.Options
Set Options2 = Document.all.todate.Options

For Count = 1 To 20-1
StrDate = "Tuesday " & Right("0" & Day(TheDate),2) & "/" &
Right("0" & Month(TheDate),2) & "/" & Year(TheDate)
Options.Add Window.Option(StrDate,"from " & StrDate)
Options2.Add Window.Option(StrDate,"to " & StrDate)
TheDate = TheDate + 7

StrDate2 = "Thursday " & Right("0" & Day(TheDate2),2) & "/" &
Right("0" & Month(TheDate2),2) & "/" & Year(TheDate2)
Options.Add Window.Option(StrDate2,"from " & StrDate2)
Options2.Add Window.Option(StrDate2,"to " & StrDate2)
TheDate2 = TheDate2 + 7
Next
End Sub

</script>

______________________________________________

The information is correct, except that every now and again the Tusdays
& Thursdays are wrong way around depending on the current date, i.e.

it should display:

Thursday 03/02/2005
Tuesday 08/02/2005

looping continuously with Tuesdays & Thursdays in the correct date
order.

I seem to get

Tuesday 08/02/2005
Thursday 03/02/2005

How can I correct this code so that no matter what the actual date is,
the data is always in the correct order ?
Appreciate your advice

Code should be written and posted with indentation to show the intended
structure.

Lines should not be allowed to be broken by the posting agent; you
should present us with code that can be read and tested directly, with
only the original faults.
For Right("0" & Day(TheDate2),2)
Right(100+Day(TheDate2),2) ' is better, at least for me

Date should be called only once; it is comparatively expensive, and can
change.

TheDate2 is not declared.

Variable names should be short or meaningful, or both.

My system does not believe document.all.date .

You seem to be saying that the first two dates (among others) are in the
wrong order. So don't bother us with the loop.

The following "Web page" suffices to show us what is needed to be shown
:-
<SCRIPT language='vbscript'>

Dim TheDate, TheDate2

TheDate2 = Date + vbThursday - WeekDay(Date)
TheDate = Date + vbTuesday - WeekDay(Date)

If TheDate < Date Then TheDate = TheDate +7

document.write TheDate, " ", TheDate2

</script>
The following transform is more illustrative :-
<SCRIPT language='vbscript'>

Dim Tue, Thu, Dt

Dt = Date
for J = 0 to 15
D = Dt + J
Thu = D + vbThursday - WeekDay(D)
Tue = D + vbTuesday - WeekDay(D)

If Tue < D Then Tue = Tue +7 ' ###

document.write D, " - ", Thu, " - ", Tue, "<br>"
next
</script>

and the line marked ### looks implausible;
if Tue < Thu makes more sense

Now
<SCRIPT language='vbscript'>

Dim Tue, Thu, Dt, SoW

Dt = Date
for J = 0 to 15
D = Dt + J

SoW = D - WeekDay(D)
Thu = SoW + vbThursday
Tue = SoW + vbTuesday
If Tue < Thu Then Tue = Tue +7

document.write D, " - ", Thu, " - ", Tue, "<br>"
next
</script>

gives me

2005-02-03 - 2005-02-03 - 2005-02-08
2005-02-04 - 2005-02-03 - 2005-02-08
2005-02-05 - 2005-02-03 - 2005-02-08
2005-02-06 - 2005-02-10 - 2005-02-15
2005-02-07 - 2005-02-10 - 2005-02-15
2005-02-08 - 2005-02-10 - 2005-02-15
2005-02-09 - 2005-02-10 - 2005-02-15
2005-02-10 - 2005-02-10 - 2005-02-15
2005-02-11 - 2005-02-10 - 2005-02-15
2005-02-12 - 2005-02-10 - 2005-02-15
2005-02-13 - 2005-02-17 - 2005-02-22
2005-02-14 - 2005-02-17 - 2005-02-22
2005-02-15 - 2005-02-17 - 2005-02-22
2005-02-16 - 2005-02-17 - 2005-02-22
2005-02-17 - 2005-02-17 - 2005-02-22
2005-02-18 - 2005-02-17 - 2005-02-22

You need to learn how to test misbehaving code - always simplify it,
testing continually, until the solution is obvious (always keep the last
failing version). Then, with the new understanding, the original can
probably be fixed.

--
© 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.
Jul 23 '05 #3

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

Similar topics

2
by: iwasinnihon | last post by:
I don't usually like to do this, but I need help. I have gone over this code and cannot figure out why it doesn't work. First of all it doesn't check to see if you have filled in the required...
4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
4
by: Skully Matjas | last post by:
I am using the following code (created by the wizard) to allow to bring my form to a particular entery. But when I edit the entery (ex: put new information into a blank cell), it puts that record...
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
3
by: Eric | last post by:
I had a windows form project that had a functions module that could control objects on the referenced main form. How would I do the same with a web project using a web form? See my windows form...
2
by: tractng | last post by:
Guys, I really need help with this. I need to creat a login page for the website. Its an existing site that connects to SQL 7 with a local user in the database called 'maya'. It was...
6
by: Greg Strong | last post by:
Hello All, Is is possible to use an ADO recordset to populate an unbound continuous Subform? I've done some Googling without much luck, so this maybe impossible, but let me try to explain...
2
by: SONIQ | last post by:
Using javascripts to validate this form. Basic operation, when a user clicks the submit order button, the javascript code must validate everything entered by the user. Please help finnish this...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
3
by: jerry101 | last post by:
Okay, so I have no knowledge with ASP and I was asked to look at this contact form because the emails aren't delivering. I'll post the whole page of code, because I am unsure at what is what...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.