473,386 Members | 1,804 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.

Need a little help :)

I have a drop down list system (works to some extent) for a date range search
that I need to do a little more. The following is a small sample from the
script:

function modify_mo_list(mo_model)
{
molist = document.forms[0].querymo2;
if (mo_model == '/01/') {
var i = 0;
molist.options[i++] = new Option('February','/02/');
molist.options[i++] = new Option('March','/03/');
molist.options[i++] = new Option('April','/04/');
molist.options[i++] = new Option('May','/05/');
molist.options[i++] = new Option('June','/06/');
molist.options[i++] = new Option('July','/07/');
molist.options[i++] = new Option('August','/08/');
molist.options[i++] = new Option('September','/09/');
molist.options[i++] = new Option('October','/10/');
molist.options[i++] = new Option('November','/11/');
molist.options[i++] = new Option('December','/12/');
molist.options[i++] = new Option('January','/01/');
molist.options.length = i;
}
}

The entire list is comprised of Months Jan-Dec and years 1990-2006. I have it
automatically selecting the next month, when the user selects June in the first
box it automatically changes the second box to July. The year also when changed
updates the next year box. But what I also need is for the year to advance 1
year if December is selected, so that the search is from December 2000 to
January 2001. Right now it will display December 2000 to January 2000. However
when the actual searching takes place in my cgi it searches based on the input,
having those dates as input it will actually search and print everything it
finds except what is between those dates as it is looking for greater than
December 2000 and less than January 2000.

So basically I need it to change the date as it does for all months other than
December, where it is to change the year to the next year.

I have tried so many things to no avail. If someone has a suggestion let me
know.

You can view a working sample here:
<a href="http://www.inspirationaldistributors.com/search4date.html">
http://www.inspirationaldistributors...arch4date.html
</a> You should also be able to see the source code for how it works there also
so you can see all the code involved.

Thanks for any help

Jeff C
Jul 20 '05 #1
7 1644
Ivo

"Keyed4U" <ke*****@aol.com> wrote in message
news:20***************************@mb-m15.aol.com...
I have a drop down list system (works to some extent) for a date range search
I have it automatically selecting the next month, when the user selects June in the first box it automatically changes the second box to July. The year also when changed updates the next year box. But what I also need is for the year to advance 1 year if December is selected, so that the search is from December 2000 to
January 2001. Right now it will display December 2000 to January 2000.
You can view a working sample here:
http://www.inspirationaldistributors...arch4date.html
Thanks for any help
Jeff C


I was just working on some PHP script which does the same also for days,
given an array $getDaysInMonth(31,28/29,31,30,31,etc.). See if you can
convert it to javascript:

function adjustDate($day,$month, $year) {
$a = array($day,$month,$year);
while ($a[0] > getDaysInMonth($a[1], $a[2])) {$a[0] -=
getDaysInMonth($a[1], $a[2]); $a[1]++;while ($a[1] > 12) { $a[1] -= 12;
$a[2]++;}}
while ($a[0] <= 0) { $a[0] += getDaysInMonth($month, $year); $a[1]--; while
($a[1] <= 0) { $a[1] += 12; $a[2]--; }}
while ($a[1] > 12) { $a[1] -= 12; $a[2]++; }
while ($a[1] <= 0) { $a[1] += 12; $a[2]--; }
return $a;
}
Jul 20 '05 #2
Ivo

"Ivo" <no@thank.you> wrote in message
news:3f*********************@news.wanadoo.nl...

"Keyed4U" <ke*****@aol.com> wrote in message
news:20***************************@mb-m15.aol.com...
I have a drop down list system (works to some extent) for a date range search
I have it
automatically selecting the next month, when the user selects June in the first
box it automatically changes the second box to July. The year also when changed
updates the next year box. But what I also need is for the year to

advance 1
year if December is selected, so that the search is from December 2000

to January 2001. Right now it will display December 2000 to January 2000.
You can view a working sample here:
http://www.inspirationaldistributors...arch4date.html
Thanks for any help
Jeff C


I was just working on some PHP script which does the same also for days,
given an array $getDaysInMonth(31,28/29,31,30,31,etc.). See if you can
convert it to javascript:

function adjustDate($day,$month, $year) {
$a = array($day,$month,$year);
while ($a[0] > getDaysInMonth($a[1], $a[2])) {
$a[0] -= getDaysInMonth($a[1], $a[2]);
$a[1]++;while ($a[1] > 12) { $a[1] -= 12; $a[2]++;}
}
while ($a[0] <= 0) {
$a[0] += getDaysInMonth($month, $year);
$a[1]--; while ($a[1] <= 0) { $a[1] += 12; $a[2]--; }
}
while ($a[1] > 12) { $a[1] -= 12; $a[2]++; }
while ($a[1] <= 0) { $a[1] += 12; $a[2]--; }
return $a;
}


Went too fast. getDaysInMonth is a function that considers the year in its
second argument, so that we can determine February.
HTH
I
Jul 20 '05 #3
Lee
Keyed4U said:

I have a drop down list system (works to some extent) for a date range search
that I need to do a little more. The following is a small sample from the
script:


Let the built-in Date() object do the calculations for you:
<html>
<head>
<script type="text/javascript">
function update(f){
if(f.m0.selectedIndex && f.y0.selectedIndex){
m0=f.m0.selectedIndex;
y0=1989+f.y0.selectedIndex;
date1=new Date(y0,m0,1);
f.m1.selectedIndex=date1.getMonth()+1;
f.y1.selectedIndex=date1.getFullYear()-1989;
}
}
</script>
</head>
<body>
<form>
<select name="m0" onchange="update(this.form)">
<option>Choose Month</option>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<select name="y0" onchange="update(this.form)">
<option>Choose Year</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1998</option>
<option>1999</option>
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
</select>
<br>
<select name="m1">
<option>Choose Month</option>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<select name="y1">
<option>Choose Year</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1993</option>
<option>1994</option>
<option>1995</option>
<option>1996</option>
<option>1997</option>
<option>1998</option>
<option>1999</option>
<option>2000</option>
<option>2001</option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
<option>2007</option>
</select>
</form>
</body>
</html>

Jul 20 '05 #4
Thanks for the help, it seems that the built-in date function does in deed work
perfect. Again it was much appreciated. I usually stick to cgi, but for this
small project I wanted to reduce the number of scripts in the cgi directory for
me to have to keep track of!!

Jeff C
Jul 20 '05 #5
JRS: In article <20***************************@mb-m15.aol.com>, seen in
news:comp.lang.javascript, Keyed4U <ke*****@aol.com> posted at Sat, 27
Sep 2003 02:34:34 :-

Please use an informative Subject line.
So basically I need it to change the date as it does for all months other than
December, where it is to change the year to the next year.
with (DateObj) setMonth(getMonth()+1) // can use UTC.
I have tried so many things to no avail. If someone has a suggestion let me
know.
The FAQ? see below.
You can view a working sample here:


Not helpful to those who read News off-line. A clear and unambiguous
description of the need is better.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #6
Thanks to those who were actually helpful, and not to those that just can't
help or explain, but rather complain about how a post is written. If you can't
help out on the newsgroup posts, just don't bother commenting.

Again thanks to the folks who DID give sample code and helpful information.
Jul 20 '05 #7
ke*****@aol.com (Keyed4U) writes:
Thanks to those who were actually helpful, and not to those that
just can't help or explain, but rather complain about how a post is
written. If you can't help out on the newsgroup posts, just don't
bother commenting.


Sorry, but that attitude will not help get you answers from people who
can help you.

The suggestions on how to post are, to quote Matrix, for your
protection. Following them will make it more likely that you get the
help you need.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #8

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

Similar topics

19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
22
by: OHM \( Terry Burns \) | last post by:
I was thinking about community the other day, and wondering what would be the holy grail for a developer in need. I mean, we do get help here, but its done on a best endeavours basis and its really...
5
by: Grant Olson | last post by:
I'm feeling a little guilty here. I spent a lot of my free time last year working on an x86 compiler for python. I made a reasonable amount of progress, but my interests wandered off into other...
5
by: bean330 | last post by:
Hey, I'm somewhat new to C# and I need a little help, please! I'm selecting a bunch of records, setting properties on a COM executable and then calling a method on that executable to run. I...
6
by: shapper | last post by:
Hello, I am creating a form that includes a few JQuery scripts and TinyMCE Editor: http://www.27lamps.com/Beta/Form/Form.html I am having a few problems with my CSS: 1. Restyling the Select
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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.