K
kirke
Hi. I want to make a list of days between two days.
How can I make it???
Thx.
How can I make it???
Thx.
kirke said:Hi. I want to make a list of days between two days.
How can I make it???
Thx.
kirke said:Hi. I want to make a list of days between two days.
How can I make it???
Thx.
Try:
<script type="text/javascript">
function showDays(f){
var selS = f.startDay;
var selE = f.endDay;
var days = [];
var i = 0;
while (i<7 && !selS.options.selected){
i++;
}
while (!selE.options.selected){
days.push(selE.options[i++].text);
i = i%7;
}
days.push(selE.options.text);
f.dayList.value = days.join('\n');
}
</script>
<form action="">
<div>
<label for="startDay">Start day:
<select name="startDay">
<option value="0" selected>Monday
<option value="1">Tuesday
<option value="2">Wednesday
<option value="3">Thursday
<option value="4">Friday
<option value="5">Saturday
<option value="6">Sunday
</select></label>
<label for="endDay">End day:
<select name="endDay">
<option value="0">Monday
<option value="1">Tuesday
<option value="2">Wednesday
<option value="3">Thursday
<option value="4">Friday
<option value="5">Saturday
<option value="6" selected>Sunday
</select></label>
<input type="button" value="Show day list"
onclick="showDays(this.form);">
<br>
<textarea readonly name="dayList" cols=10
rows=8></textarea>
</div>
</form>
kirke said:Wow. yours are great.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.
kirke said:Wow. yours are great.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.
Wow. yours are great.
However, I took a mistake. I mean date not day.SORRY.
Thus, start date is 10/19/2006 and end date is 10/31/2006 Then.
I want to make a list of 10/19/2006, 10/20/2006,....,10/30/2006,
10/31/2006 like this.
Try the Date object.
I.e.
var d = new Date(2006,9,19);
var d2 = new Date(2006,10,31);
var aDates = [];
do
{
aDates.push(d.toString());
d.setDate(d.getDate()+1);
}
while (d <= d2);
alert(aDates.join("\r\n"));
Thu said:To keep up with the OQ, without using the localized version:
<script type='text/javascript'>
var d = new Date(2006,9,19);
As well as the OP not having defined "day", he or she did not indicate
whether "between" means "between" or is intended to be inclusive.
Selection of while-do or do-while loop and of terminal condition should
fix that.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.