473,786 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automatically fill in dates

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:sc hemas-microsoft-com:vml"
xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<TITLE>Outlin e Example</TITLE>
</HEAD>
<BODY>

<table border="1" width="100%" id="table13">
<tr>
<td width="424">Nam e:&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;
<INPUT TYPE=text NAME="name_57" SIZE="20" MAXLENGTH="100"
VALUE=""></td>
<td width="258">Dat e:&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="JavaS cript" 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.getEl ementById) {
document.getEle mentById('recip _' + i).style.displa y = '';
} else if (document.all) {
document.all['recip_' + i].style.display = '';
}
}
} else {
for (var i = s.options.lengt h; i > 1; i--) {
if (document.getEl ementById) {
document.getEle mentById('recip _' + i).style.displa y = 'none';
} else if (document.all) {
document.all['recip_' + i].style.display = 'none';
}
}
}

}
</SCRIPT> <tr>
<td width="103">&nb sp;</td>
<td width="119">&nb sp;</td>
<td width="123">&nb sp;</td>
<td width="117">&nb sp;</td>
<td>&nbsp;</td>
</tr>
</table>&nbsp;</DIV>
<table x:str border=0 cellpadding=0 cellspacing=0
style='border-collapse:
collapse;table-layout:fixed;wi dth:741px' id="table4">
<tr height=25 style='mso-height-source:userset; height:18.95pt' >
<td rowspan=4 height=100 style='border:m edium none; padding:0px;
background:silv er; height:75.8pt;c olor: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">&nbs p;</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:windowtex t; font-size:10.0pt;
text-decoration:none ; vertical-align:bottom'>D ATE</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" bordercolorligh t="#000000" height="120">
<tr>
<td width="42" align="center" height="30">&nb sp;</td>
<td width="43" align="center" height="30"><b> &nbsp; </b></td>
<td width="44" align="center" height="30">&nb sp;</td>
<td width="44" align="center" height="30">&nb sp;</td>
<td width="45" align="center" height="30">&nb sp;</td>
<td width="40" align="center" height="30">&nb sp;</td>
<td align="center" height="30">&nb sp;</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">&nb sp;</td>
<td height="30" width="43">&nbs p;</td>
<td height="30" width="44">&nbs p;</td>
<td height="30" width="44">&nbs p;</td>
<td height="30" width="45">&nbs p;</td>
<td height="30" width="40">&nbs p;</td>
<td height="30">&nb sp;</td>
</tr>
<tr>
<td width="42" height="28">&nb sp;</td>
<td height="28" width="43">&nbs p;</td>
<td height="28" width="44">&nbs p;</td>
<td height="28" width="44">&nbs p;</td>
<td height="28" width="45">&nbs p;</td>
<td height="28" width="40">&nbs p;</td>
<td height="28">&nb sp;</td>
</tr>
</table>
</td>
<td rowspan=4 style='border:m edium none; padding:0px;
background:silv er; color:windowtex t; 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">&nb sp;</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:windowtex t; font-size:10.0pt; text-decoration:none ;
vertical-align:bottom'>D AY</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:windowtex t; 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:windowtex t; font-size:10.0pt;
text-decoration:none ; vertical-align:bottom; white-space:nowrap'
width="80">BOAR D</td>
</tr>
</table>

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

</BODY>
</HTML>

Jul 23 '05 #1
8 2241
I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetic al" 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>&nbs p;<INPUT TYPE=text
ID=Amount1 Name=Amount1 Value=""">&nbsp ;
Thursday....&qu ot;2/3/05&quot; automatically fills here.</p>

<p><INPUT TYPE=text ID=Amount2 Name=Amount2 Value=""">&nbsp ;&nbsp;
Friday.....&quo t;2/4/05&quot; automatically fills here.</p>
<p><INPUT TYPE=text ID=Amount3 Name=Amount3 Value=""">&nbsp ;
Saturday....&qu ot;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....&quo t;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>

Jul 23 '05 #2
JRS: In article <11************ **********@l41g 2000cwc.googleg roups.com>
, dated Mon, 7 Feb 2005 07:42:21, seen in news:comp.lang. javascript,
netsurfer <ne**********@y ahoo.com> posted :

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.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<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.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #3
netsurfer wrote:
I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetic al" 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....&qu ot;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','Febr uary','March',' April','May','J une','July',
'August','Septe mber','October' ,'November','De cember'];

var days = ['Sunday','Monda y','Tuesday','W ednesday',
'Thursday','Fri day','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.val ue.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(s Date.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.getD ate())
+ ' ' + months[sDate.getMonth( )]
+ ', ' + sDate.getFullYe ar();

// Get the field to write to
if (document.getEl ementById) {
slot = document.getEle mentById('day' + i);
} else if (document.all) {
slot = document.all('d ay' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChil d) {
slot.removeChil d(slot.firstChi ld);
}

// Add a text node with the date string in it
slot.appendChil d(document.crea teTextNode(date String));

// 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">Ente r the start date<br>(yyyy-mm-dd):</td>
<td class="dd"><INP UT TYPE="text" id="startDate"
name="startDate " value="2005-02-09"><br>
<INPUT TYPE="button" value="Set dates" onclick="
doDates(this.fo rm);
">
<input type="reset">
</td>
</tr>
<tr>
<td class="dd">Date s:</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>

--
Fred
Jul 23 '05 #4

Fred Oz wrote:
netsurfer wrote:
I'm going to try to make this concept easier to answer since the above is messy code please see my "hypothetic al" 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....&qu ot;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','Febr uary','March',' April','May','J une','July',
'August','Septe mber','October' ,'November','De cember'];

var days = ['Sunday','Monda y','Tuesday','W ednesday',
'Thursday','Fri day','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.val ue.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(s Date.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.getD ate())
+ ' ' + months[sDate.getMonth( )]
+ ', ' + sDate.getFullYe ar();

// Get the field to write to
if (document.getEl ementById) {
slot = document.getEle mentById('day' + i);
} else if (document.all) {
slot = document.all('d ay' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChil d) {
slot.removeChil d(slot.firstChi ld);
}

// Add a text node with the date string in it
slot.appendChil d(document.crea teTextNode(date String));

// 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">Ente r the start date<br>(yyyy-mm-dd):</td>
<td class="dd"><INP UT TYPE="text" id="startDate"
name="startDate " value="2005-02-09"><br>
<INPUT TYPE="button" value="Set dates" onclick="
doDates(this.fo rm);
">
<input type="reset">
</td>
</tr>
<tr>
<td class="dd">Date s:</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>

--
Fred


Ahhh...very cool..thanks Fred.

Jul 23 '05 #5
JRS: In article <4208acc3$0$189 34$5a62ac22@per-qv1-newsreader-
01.iinet.net.au >, dated Tue, 8 Feb 2005 22:11:51, seen in
news:comp.lang. javascript, Fred Oz <oz****@iinet.n et.auau> posted :
netsurfer wrote:
I'm going to try to make this concept easier to answer since the above
is messy code please see my "hypothetic al" 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.val ue.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(s Date.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.getEl ementById) {
slot = document.getEle mentById('day' + i);
} else if (document.all) {
slot = document.all('d ay' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChil d) {
slot.removeChil d(slot.firstChi ld);
}
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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #6
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","Tuesd ay","Wednesday" ,"Thursday","Fr iday","Saturday ")

//capture the entered date
enterDate = document.dateSt uff.Amount0.val ue;

// 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"+dateAr ray[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.getMont h()+1) +
"/" + sdate.getDate() + "/" +
sdate.getFullYe ar().toString() .substring(2,4) )

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

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

</script>
</head>

<body>

<form name="dateStuff ">

<p><INPUT TYPE=text ID=Amount0 Name=Amount0 Value="">
<a href="#" onClick="fillDa tes()">Enter</a>
&nbsp;&nbsp;&nb sp;&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>

Jul 23 '05 #7
Dr John Stockton wrote:
[...]
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.


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!

[...]
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!


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.
var dBits = f.startDate.val ue.split('-');


.split(/\D+/) // more lenient : '+'?


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

[...]
// Get the field to write to
if (document.getEl ementById) {
slot = document.getEle mentById('day' + i);
} else if (document.all) {
slot = document.all('d ay' + i);
}

// See if slot has any child nodes. If so, remove them
while (slot.firstChil d) {
slot.removeChil d(slot.firstChi ld);
}

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.childNo des) may return true.
sDate.setDate(+ sDate.getDate() +1);


^ not needed


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

--
Fred
Jul 23 '05 #8
JRS: In article <11************ **********@c13g 2000cwb.googleg roups.com>
, dated Tue, 8 Feb 2005 16:37:38, seen in news:comp.lang. javascript,
pj************@ gmail.com 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.Amoun t" + i + ".value = newDate")
Routine eval is a bad idea for this. Read the newsgroup FAQ.

//go back one day
sdate = new Date(sdate.getT ime() - 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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<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.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #9

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

Similar topics

3
3820
by: paul b | last post by:
Hello, I have a small problem in PHP an perhaps someone can help me: I have a simple HTML login page with a username and a password field, as well as a submit button, which I have to use for login(I cannot simply replace it by a php-page :-(). is it possible to call this page via a hyperlink from a php-script and to directly fill the username and password fields as well to raise the event of clicking the submit button.
5
2070
by: Sparrow | last post by:
I have created a table with the following columns... Date(datetime),Actual (Int),Planned (Int) I need to insert weekending dates starting from 23/04/04 looping thru'for the next 52weeks automatically into the date column. Then in the actual and planned colums, I need to insert a count of some records in the table. I will appreciate help on a SQL query to achieve this!
31
5725
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a calendar, 7 across by whatever needed down, and I manually create it each month - not a big deal. Every day I go in and darken the background color of the current day's cell by changing the appropriate <TD> entry to <TD bgcolor="c63800"> and...
3
2459
by: SJH | last post by:
I currently have reports (mostly graphs) that utilize dates entered into a form. The dates are pretty baisc from the standpoint of the start and end of the current fiscal year, the start and end of last fiscal year, previous month start and end dates, etc. My users would like to enter one set of dates (preferably the previous month start and end) and have all other dates update from there without extra input. I have the fiscal years...
1
3599
by: Johann Blake | last post by:
I have a dataset that contains a parent table and a child table. A DataRelation exists between the two. I was under the impression from reading the VS docs that when I filled the parent table, the child table would be automatically filled with the child records. When I fill the parent, I limit the table to only a single record, so that all the records in the child table will belong to this parent. But when the Fill method is executed with...
0
2735
by: neoteny2 | last post by:
I need MS Access to automatically create reports/subreports based on specific criteria. I am building a database in Access 2003 with different locations/sites. I have the "sites" table created containing site info, including an empty field for "date". I also have a report format already created displaying the site info. I need Access to ask the user for a date, calculate three additional dates using the entered date (adding or subtracting...
10
2252
by: RoadRunner | last post by:
Hi, I have a employee vacation database that has a vacation table that has the employee name, pay week and date of vacation. I have another lookup table with pay week code and date range for the week. The user would like to type in a date in the Date of Vacation field and have the Pay Week field automatically fill in. My dlookup code is not working. Here is example of what the tables look like: Employee: Name Pay Week Date of...
1
1257
by: sunboy30860 | last post by:
How to update my web automatically by python? I have one twiki web page https://twiki.cern.ch/twiki/bin/view/Atlas/CSC11DQ2ReplicateToCERNCAF In this page,the dates often need to be updated.Every time after I produce the dates ,I plaster the date to the web manual.The dates is produced by a python program.I want to write a python program to update my web automatically.I hope someone could help me.Tkanks!!
1
1328
by: John | last post by:
I made an Access application that helps with the financial administration of a company. It imports downloaded files from a bank. For the download the user has to enter the start and end date on a website. Now I would like the user to be able to press a button in the Access application so that the website gets focus and the dates on that website are entered automatically. Is this possible? Can Access interact with Internet Explorer? How...
0
9655
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
10363
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
10110
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
9964
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
7517
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
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.