Automatically fill in dates

N

netsurfer

Hi:

Have a question on making the date automatically filled in by what the
user enters in by the date at the top.

The date entered at the top would most likely be on a Wednesday then I
need to have all the prior dates pop in. Example: User enters 2/9/05
in the date field at the top being a Wednesday...I need the dates at
the bottom to be filled in automatically, respectively as 2/3/05,
2/4/05, 2/5/05, 2/6/05, 2/7/05, 2/8/05, 2/9/05 above the days Thurs.,
Fri., Sat., Sun., Mon., Tues. and Wed. See text below as HTML. Thanks
very much in advanced for any ideas:

<HTML xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:eek:="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<TITLE>Outline Example</TITLE>
</HEAD>
<BODY>

<table border="1" width="100%" id="table13">
<tr>
<td width="424">Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=text NAME="name_57" SIZE="20" MAXLENGTH="100"
VALUE=""></td>
<td width="258">Date:&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=text NAME="name_58" SIZE="20" MAXLENGTH="100"
VALUE=""></td>
<td>Job No:&nbsp;&nbsp;&nbsp;
<INPUT TYPE=text NAME="name_59" SIZE="20" MAXLENGTH="100"
VALUE=""></td>
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function reveal(s) {
var val = s.options[s.selectedIndex].value;
if (val > 1) {
for (var i = 2; i <= val; i++) {
if (document.getElementById) {
document.getElementById('recip_' + i).style.display = '';
} else if (document.all) {
document.all['recip_' + i].style.display = '';
}
}
} else {
for (var i = s.options.length; i > 1; i--) {
if (document.getElementById) {
document.getElementById('recip_' + i).style.display = 'none';
} else if (document.all) {
document.all['recip_' + i].style.display = 'none';
}
}
}

}


</SCRIPT> <tr>
<td width="103">&nbsp;</td>
<td width="119">&nbsp;</td>
<td width="123">&nbsp;</td>
<td width="117">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>&nbsp;</DIV>
<table x:str border=0 cellpadding=0 cellspacing=0
style='border-collapse:
collapse;table-layout:fixed;width:741px' id="table4">
<tr height=25 style='mso-height-source:userset;height:18.95pt'>
<td rowspan=4 height=100 style='border:medium none; padding:0px;
background:silver; height:75.8pt;color:windowtext; font-size:10.0pt;
font-weight:400; font-style:normal; text-decoration:none;
font-family:Arial; text-align:general; vertical-align:bottom;
white-space:nowrap' width="80">&nbsp;</td>
<td style='border-left:.5pt solid windowtext; border-right:1.0pt
solid windowtext; border-top:medium none; border-bottom:.5pt solid
windowtext; padding:0px; width:80px; font-weight:700;
font-style:italic; font-family:Arial, sans-serif; text-align:center;
white-space:normal; color:windowtext; font-size:10.0pt;
text-decoration:none; vertical-align:bottom'>DATE</td>
<td align=left valign=top style="color: windowtext; font-size:
10.0pt; font-weight: 400; font-style: normal; text-decoration: none;
font-family: Arial; text-align: general; vertical-align: bottom;
white-space: nowrap; border: medium none; padding: 0px" width="325"
rowspan="4">
<table border="1" width="100%" id="table12" cellspacing="0"
cellpadding="0" bordercolorlight="#000000" height="120">
<tr>
<td width="42" align="center" height="30">&nbsp;</td>
<td width="43" align="center" height="30"><b>&nbsp; </b></td>
<td width="44" align="center" height="30">&nbsp;</td>
<td width="44" align="center" height="30">&nbsp;</td>
<td width="45" align="center" height="30">&nbsp;</td>
<td width="40" align="center" height="30">&nbsp;</td>
<td align="center" height="30">&nbsp;</td>
</tr>
<tr>
<td width="42" height="30" align="center"><b><font
size="2">THUR.</font></b></td>
<td height="30" width="43" align="center"><b><font
size="2">FRI.</font></b></td>
<td height="30" width="44" align="center"><b><font
size="2">SAT.</font></b></td>
<td height="30" width="44" align="center"><b><font
size="2">SUN.</font></b></td>
<td height="30" width="45" align="center"><b><font
size="2">MON.</font></b></td>
<td height="30" width="40" align="center"><b><font
size="2">TUES.</font></b></td>
<td height="30" align="center"><b><font
size="2">WED.</font></b></td>
</tr>
<tr>
<td width="42" height="30">&nbsp;</td>
<td height="30" width="43">&nbsp;</td>
<td height="30" width="44">&nbsp;</td>
<td height="30" width="44">&nbsp;</td>
<td height="30" width="45">&nbsp;</td>
<td height="30" width="40">&nbsp;</td>
<td height="30">&nbsp;</td>
</tr>
<tr>
<td width="42" height="28">&nbsp;</td>
<td height="28" width="43">&nbsp;</td>
<td height="28" width="44">&nbsp;</td>
<td height="28" width="44">&nbsp;</td>
<td height="28" width="45">&nbsp;</td>
<td height="28" width="40">&nbsp;</td>
<td height="28">&nbsp;</td>
</tr>
</table>
</td>
<td rowspan=4 style='border:medium none; padding:0px;
background:silver; color:windowtext; font-size:10.0pt; font-weight:400;
font-style:normal; text-decoration:none; font-family:Arial;
text-align:general; vertical-align:bottom; white-space:nowrap'
width="256">&nbsp;</td>
</tr>
<tr height=25 style='mso-height-source:userset;height:18.95pt'>
<td height=25 style='border-left:.5pt solid windowtext;
border-right:1.0pt solid windowtext; border-top:medium none;
border-bottom:.5pt solid windowtext; padding:0px;
height:18.95pt;width:80px; font-weight:700; font-style:italic;
font-family:Arial, sans-serif; text-align:center; white-space:normal;
color:windowtext; font-size:10.0pt; text-decoration:none;
vertical-align:bottom'>DAY</td>
</tr>
<tr height=25 style='mso-height-source:userset;height:18.95pt'>
<td height=25 style='border-left:.5pt solid windowtext;
border-right:1.0pt solid windowtext; border-bottom:.5pt solid
windowtext; padding:0px; height:18.95pt;border-top:medium none; ;
font-weight:700; font-style:italic; font-family:Arial, sans-serif;
text-align:center; color:windowtext; font-size:10.0pt;
text-decoration:none; vertical-align:bottom; white-space:nowrap'
width="80">ROOM</td>
</tr>
<tr height=25 style='mso-height-source:userset;height:18.95pt'>
<td height=25 style='border-left:.5pt solid windowtext;
border-right:1.0pt solid windowtext; border-top:medium none;
border-bottom:1.0pt solid windowtext; padding:0px; height:18.95pt;
font-weight:700; font-style:italic; font-family:Arial, sans-serif;
text-align:center; color:windowtext; font-size:10.0pt;
text-decoration:none; vertical-align:bottom; white-space:nowrap'
width="80">BOARD</td>
</tr>
</table>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</BODY>
</HTML>
 
N

netsurfer

I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetical" example and tell me how I
can get dates automatically entered in with this HTML document:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<INPUT TYPE=text ID=Amount1 Name=Amount1 Value=""">&nbsp; Date gets
entered
here. Example user enters &quot;2/9/05&quot;<p>&nbsp;<INPUT TYPE=text
ID=Amount1 Name=Amount1 Value=""">&nbsp;
Thursday....&quot;2/3/05&quot; automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount2 Name=Amount2 Value=""">&nbsp;&nbsp;
Friday.....&quot;2/4/05&quot; automatically fills here.</p>
<p><INPUT TYPE=text ID=Amount3 Name=Amount3 Value=""">&nbsp;
Saturday....&quot;2/5/05&quot; automatically fills here.</p>
<p><INPUT TYPE=text ID=Amount4 Name=Amount4 Value=""">&nbsp;&nbsp;
Sunday....&quot;2/6/05&quot; automatically fills here.</p>
<p><INPUT TYPE=text ID=Amount5 Name=Amount5 Value=""">&nbsp;&nbsp;
Monday...&quot;2/7/05&quot; automatically fills here.</p>
<p><INPUT TYPE=text ID=Amount6 Name=Amount6 Value=""">&nbsp;
Tuesday....&quot;2/8/05&quot;
automatically fills in here.</p>
<p><INPUT TYPE=text ID=Amount7 Name=Amount7 Value=""">&nbsp;&nbsp;
Wednesday......&quot;2/9/05&quot; automatically fills in here.</p>

</body>

</html>
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Mon, 7 Feb 2005 07:42:21, seen in
netsurfer said:
The date entered at the top would most likely be on a Wednesday then I
need to have all the prior dates pop in. Example: User enters 2/9/05
in the date field at the top being a Wednesday...I need the dates at
the bottom to be filled in automatically, respectively as 2/3/05,
2/4/05, 2/5/05, 2/6/05, 2/7/05, 2/8/05, 2/9/05 above the days Thurs.,
Fri., Sat., Sun., Mon., Tues. and Wed. See text below as HTML. Thanks
very much in advanced for any ideas:

Read the newsgroup FAQ.

When posting code, do not allow your posting agent to wrap lines; code
should be executable as transmitted.

Don't post excess code. In particular, most scripts should work without
CSS, so strip out CSS and as much else as possible. Then test your
reduced page to check that it still shows what needs to be shown, and no
more.

Explain where your problem actually lies; does it lie in the execution
of code after data entry, or the computation of the dates, in the
representation as date strings, or in the emplacement of those strings?

Avoid FFF on the WWW.

Don't fix font sizes in points, it is a breach of the DDA, if you
provide a public service.

http://validator.w3.org/ will probably give a number of warnings about
your HTML.
 
F

Fred Oz

netsurfer said:
I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetical" example and tell me how I
can get dates automatically entered in with this HTML document:

Thanks for cleaning up your code, at least a little.

[...]
<INPUT TYPE=text ID=Amount1 Name=Amount1 Value=""">&nbsp; Date gets

All attributes should be quoted, and that extra " at the end
will upset most browsers.

You only need both id and name attributes on form elements under
certain circumstances, it is not needed here. Just use name.
And if you aren't going to give the input a value, why include an
empty value attribute? It's optional, it isn't required and
just gives more code to maintain (and you've got an error...)

I also would not use input fields for the generated dates as
users will likely try to modify them (unless you want your users
modifying the dates).

[...]
Thursday....&quot;2/3/05&quot; automatically fills here.</p>

Do not assume US dates. Always specify input formats and units
where appropriate. Assume your users are really dumb (but don't
*treat* them as dumb). Make everything obvious with subtle but
concise and accurate help.

[...]

It seems you are trying to create a Hegira week - or am I way
off? The code below creates a set of dates from Thu to the
following Wed that includes the input date.

It does not validate the input - you need to do that. You need
to check that integers within an appropriate range have been
entered, I'll leave that up to you.


<html><head>
<title>Date Play</title>
<style type="text/css">
body {font-family: sans-serif;}
..dd {text-align: center;}
..od {text-align: right; border: 1px solid blue; width: 15em;}
</style>
<script type="text/javascript">

var months =
['January','February','March','April','May','June','July',
'August','September','October','November','December'];

var days = ['Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday']

function doDates(f) {

var slot; // will store a reference to the output element

// Get the input text and divide into bits
var dBits = f.startDate.value.split('-');

/* Code here to validate input
....
*/

// If passes validation, create a date at noon on date entered
var sDate = new Date(dBits[0],dBits[1]-1,dBits[2],'12');

// Go backward through week to Thursday
while ( days[sDate.getDay()] != days[4]) {
sDate.setDate(sDate.getDate()-1);
}

// Write the days of the week to the fields
for (var i=0; i<7; i++){
var dateString = days[sDate.getDay()]
+ ', ' + addZ(sDate.getDate())
+ ' ' + months[sDate.getMonth()]
+ ', ' + sDate.getFullYear();

// Get the field to write to
if (document.getElementById) {
slot = document.getElementById('day' + i);
} else if (document.all) {
slot = document.all('day' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChild) {
slot.removeChild(slot.firstChild);
}

// Add a text node with the date string in it
slot.appendChild(document.createTextNode(dateString));

// Add one day to the date
sDate.setDate(+sDate.getDate()+1);
}
}


// Adds a leading zero to single digit numbers
function addZ(x) {
return (x<10)? '0'+x:x;
}
</script>

</head>
<body>

<form action="">
<table>
<tr>
<td class="dd">Enter the start date<br>(yyyy-mm-dd):</td>
<td class="dd"><INPUT TYPE="text" id="startDate"
name="startDate" value="2005-02-09"><br>
<INPUT TYPE="button" value="Set dates" onclick="
doDates(this.form);
">
<input type="reset">
</td>
</tr>
<tr>
<td class="dd">Dates:</td>
<td>
<p class="od">
<span id="day0">&nbsp;</span><br>
<span id="day1">&nbsp;</span><br>
<span id="day2">&nbsp;</span><br>
<span id="day3">&nbsp;</span><br>
<span id="day4">&nbsp;</span><br>
<span id="day5">&nbsp;</span><br>
<span id="day6">&nbsp;</span>
</p>
</td>
</tr>
</table>
</form>

</body>

</html>
 
N

netsurfer

Fred said:
netsurfer said:
I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetical" example and tell me how I
can get dates automatically entered in with this HTML document:

Thanks for cleaning up your code, at least a little.

[...]
<INPUT TYPE=text ID=Amount1 Name=Amount1 Value=""">&nbsp; Date gets

All attributes should be quoted, and that extra " at the end
will upset most browsers.

You only need both id and name attributes on form elements under
certain circumstances, it is not needed here. Just use name.
And if you aren't going to give the input a value, why include an
empty value attribute? It's optional, it isn't required and
just gives more code to maintain (and you've got an error...)

I also would not use input fields for the generated dates as
users will likely try to modify them (unless you want your users
modifying the dates).

[...]
Thursday....&quot;2/3/05&quot; automatically fills here.</p>

Do not assume US dates. Always specify input formats and units
where appropriate. Assume your users are really dumb (but don't
*treat* them as dumb). Make everything obvious with subtle but
concise and accurate help.

[...]

It seems you are trying to create a Hegira week - or am I way
off? The code below creates a set of dates from Thu to the
following Wed that includes the input date.

It does not validate the input - you need to do that. You need
to check that integers within an appropriate range have been
entered, I'll leave that up to you.


<html><head>
<title>Date Play</title>
<style type="text/css">
body {font-family: sans-serif;}
.dd {text-align: center;}
.od {text-align: right; border: 1px solid blue; width: 15em;}
</style>
<script type="text/javascript">

var months =
['January','February','March','April','May','June','July',
'August','September','October','November','December'];

var days = ['Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday']

function doDates(f) {

var slot; // will store a reference to the output element

// Get the input text and divide into bits
var dBits = f.startDate.value.split('-');

/* Code here to validate input
....
*/

// If passes validation, create a date at noon on date entered
var sDate = new Date(dBits[0],dBits[1]-1,dBits[2],'12');

// Go backward through week to Thursday
while ( days[sDate.getDay()] != days[4]) {
sDate.setDate(sDate.getDate()-1);
}

// Write the days of the week to the fields
for (var i=0; i<7; i++){
var dateString = days[sDate.getDay()]
+ ', ' + addZ(sDate.getDate())
+ ' ' + months[sDate.getMonth()]
+ ', ' + sDate.getFullYear();

// Get the field to write to
if (document.getElementById) {
slot = document.getElementById('day' + i);
} else if (document.all) {
slot = document.all('day' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChild) {
slot.removeChild(slot.firstChild);
}

// Add a text node with the date string in it
slot.appendChild(document.createTextNode(dateString));

// Add one day to the date
sDate.setDate(+sDate.getDate()+1);
}
}


// Adds a leading zero to single digit numbers
function addZ(x) {
return (x<10)? '0'+x:x;
}
</script>

</head>
<body>

<form action="">
<table>
<tr>
<td class="dd">Enter the start date<br>(yyyy-mm-dd):</td>
<td class="dd"><INPUT TYPE="text" id="startDate"
name="startDate" value="2005-02-09"><br>
<INPUT TYPE="button" value="Set dates" onclick="
doDates(this.form);
">
<input type="reset">
</td>
</tr>
<tr>
<td class="dd">Dates:</td>
<td>
<p class="od">
<span id="day0">&nbsp;</span><br>
<span id="day1">&nbsp;</span><br>
<span id="day2">&nbsp;</span><br>
<span id="day3">&nbsp;</span><br>
<span id="day4">&nbsp;</span><br>
<span id="day5">&nbsp;</span><br>
<span id="day6">&nbsp;</span>
</p>
</td>
</tr>
</table>
</form>

</body>

</html>

Ahhh...very cool..thanks Fred.
 
D

Dr John Stockton

JRS: In article <4208acc3$0$18934$5a62ac22@per-qv1-newsreader-
01.iinet.net.au>, dated Tue, 8 Feb 2005 22:11:51, seen in
news:comp.lang.javascript said:
netsurfer said:
I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetical" example and tell me how I
can get dates automatically entered in with this HTML document:

Thanks for cleaning up your code, at least a little.

[...]
<INPUT TYPE=text ID=Amount1 Name=Amount1 Value=""">&nbsp; Date gets

All attributes should be quoted, and that extra " at the end
will upset most browsers.

Where an attribute is a pure alphanumeric identifier, then IMHO quoting
just adds to bloat, clutter, and the possibility of misquoting.

MSIE4 did not mind """; but of course W3's TIDY disliked it.

You only need both id and name attributes on form elements under
certain circumstances, it is not needed here. Just use name.

Agreed - but, more importantly, different but nearby elements should
have different names/IDs. The OP had two Amount1 fields.

I also would not use input fields for the generated dates as
users will likely try to modify them (unless you want your users
modifying the dates).

They are, however, easy to address; and using readonly tends to
inhibit modification (what percentage of installed browsers honour
readonly?). In some contexts, they can be used to provide an indication
that the field is, or will be, calculated and is not supplied in HTML.
In this context, that is not needed.

Do not assume US dates.
It does not validate the input - you need to do that. You need
to check that integers within an appropriate range have been
entered, I'll leave that up to you.

You don't need to, taking that literally. Checking day-of-month in
1..31 allows Feb 30th, whereas by using a Date Object a full check of
field values can be done in a couple of lines - read the newsgroup FAQ!

var dBits = f.startDate.value.split('-');
.split(/\D+/) // more lenient : '+'?
// If passes validation, create a date at noon on date entered
var sDate = new Date(dBits[0],dBits[1]-1,dBits[2],'12');

That can be done during full validation; the hours need not be a string,
and can be omitted (864e5 is not used).

// Go backward through week to Thursday
while ( days[sDate.getDay()] != days[4]) {
sDate.setDate(sDate.getDate()-1);
}

with (sDate) setDate(getDate() - (n + getDay())%7)

should do that in one move, with n=3 for Thursday; and your array
lookups are superfluous.

// Get the field to write to
if (document.getElementById) {
slot = document.getElementById('day' + i);
} else if (document.all) {
slot = document.all('day' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChild) {
slot.removeChild(slot.firstChild);
}

Are there browsers with .firstChild but not getElementById ?

sDate.setDate(+sDate.getDate()+1);
^ not needed




The OP needs to read the newsgroup FAQ, section 2.3, if he wants to
deserve assistance.
 
G

Guest

Something simple that works, and sticks close to your original post:

<html>

<head>
<script>
function fillDates(){
//set array of weekdays
var weekday=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")

//capture the entered date
enterDate = document.dateStuff.Amount0.value;

// DO SOME ERROR HANDLING HERE CHECK FOR VALID DATE (MM/DD/YY) !!!!!

//split date into individual pieces
var dateArray = enterDate.split('/')

//translate the string '05' to '2005'
dateArray[2] = "20"+dateArray[2]

//assemble date object
sdate = new Date(dateArray[2],dateArray[0]-1,dateArray[1])


//work backwards through date fields
for (i = 7; i >= 1; i--){
//assemble date
newDate = weekday[sdate.getDay()] + " " + ((sdate.getMonth()+1) +
"/" + sdate.getDate() + "/" +
sdate.getFullYear().toString().substring(2,4))

//write date
eval("document.dateStuff.Amount" + i + ".value = newDate")

//go back one day
sdate = new Date(sdate.getTime() - 86400000);
}


}

</script>


</head>

<body>

<form name="dateStuff">

<p><INPUT TYPE=text ID=Amount0 Name=Amount0 Value="">
<a href="#" onClick="fillDates()">Enter</a>
&nbsp;&nbsp;&nbsp;&nbsp;Date gets entered here. Example user enters
"2/9/05"</p>

<p><INPUT TYPE=text ID=Amount1 Name=Amount1 Value="">
Thursday...."2/3/05" automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount2 Name=Amount2 Value="">
Friday....."2/4/05" automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount3 Name=Amount3 Value="">
Saturday...."2/5/05" automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount4 Name=Amount4 Value="">
Sunday...."2/6/05" automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount5 Name=Amount5 Value="">
Monday..."2/7/05" automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount6 Name=Amount6 Value="">
Tuesday...."2/8/05" automatically fills in here.</p>

<p><INPUT TYPE=text ID=Amount7 Name=Amount7 Value="">
Wednesday......"2/9/05" automatically fills in here.</p>

</form>

</body>

</html>
 
F

Fred Oz

Dr John Stockton wrote:
[...]
Where an attribute is a pure alphanumeric identifier, then IMHO quoting
just adds to bloat, clutter, and the possibility of misquoting.

The operative word being "should", not must. The w3c HTML 4.01
spec says:

3.2.2 Attributes

Elements may have associated properties, called attributes,
which may have values...

By default, SGML requires that all attribute values be
delimited using either double quotation marks (ASCII decimal
34) or single quotation marks (ASCII decimal 39).

...

In certain cases, authors may specify the value of an
attribute without any quotation marks. The attribute value may
only contain letters (a-z and A-Z), digits (0-9), hyphens
(ASCII decimal 45), periods (ASCII decimal 46), underscores
(ASCII decimal 95), and colons (ASCII decimal 58). We
recommend using quotation marks even when it is possible to
eliminate them.

<URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2>

AFAIK, every example in the HTML 4.01 spec uses quoted attribute
values - so whilst it isn't required, I think it's a good idea.
MSIE4 did not mind """; but of course W3's TIDY disliked it.

Contrary to my post, most browsers probably will tolerate it,
but it sure messed with my text editor's syntax colouring!

[...]
You don't need to, taking that literally. Checking day-of-month in
1..31 allows Feb 30th, whereas by using a Date Object a full check of
field values can be done in a couple of lines - read the newsgroup FAQ!

I was thinking more along the lines of dates permitted within
the OP's application logic - say within one month of today. I
should have said 'dates', not 'integers' ... my bad.
.split(/\D+/) // more lenient : '+'?

Yes, great idea - allows and delimiter. But what to use for
on-screen help?

[...]
Are there browsers with .firstChild but not getElementById ?

Point taken, but the other choices were:
- put the same "while" on both sides of the else (ugh, bloat)
- use a DynWrite type solution - seems over the top for this
- add:
} else {
alert('Your browser ain\'t supported by this script');
return false;
}

Incidentally, I used firstChild rather than childNodes 'cos
Safari doesn't support access to the childNodes collection,
even though (eleRef.childNodes) may return true.
^ not needed

The "+" is not needed to ensure the "1" is added rather than
appended, but to my mind it improves readability.
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Tue, 8 Feb 2005 16:37:38, seen in (e-mail address removed) posted :
Something simple that works, and sticks close to your original post:

You have posted your article as a follow-up to mine, yet yours is
unrelated to mine. You have not given proper quoting or attribution.
You have allowed your posting agent to wrap code lines. Please find out
how to post correctly.


//write date
eval("document.dateStuff.Amount" + i + ".value = newDate")

Routine eval is a bad idea for this. Read the newsgroup FAQ.

//go back one day
sdate = new Date(sdate.getTime() - 86400000);

Naive. Though (the page is obviously suited only to Murricans, as it
has FFF dates) it will suffice for users in much of Arizona, in Hawaii,
and in most of southern Indiana; and in non-contiguous territories
(American Samoa, Guam, Puerto Rico, the Virgin Islands).

Test it over the first Sunday on April, if you are in the rest of the
USA; the last one of March, if in the EU; about six months later, if
Antipodean (not Que, NT, WA, though).

Discover the difference between Date and Time.

Read the newsgroup FAQ.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top