473,324 Members | 2,501 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,324 software developers and data experts.

What the he** am I missing here?

function SetDefaultDate() {
d = new Date();
return d;
}
........
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>
I just want to default the html control to todays date.

Why is this all so painful......maybe time for a career change :(
Jul 20 '05 #1
28 1780
@SM


Brent Eamer a ecrit :

function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
may be ... ?

value="<SCRIPT>document.write(SetDefaultDate())</SCRIPT>">
</TD>
</TR>

Jul 20 '05 #2
Brent Eamer wrote on 18 Dec 2003 at Thu, 18 Dec 2003 13:11:36 GMT:
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1"
maxlength="50" value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>


I was going to say: "That SCRIPT block is being interpreted as it's
supposed to be in that context: a CDATA (string) value." But when I
checked the HTML standard (to check that value attributes contain
CDATA), I realised that SELECT elements don't have value attributes;
the selected OPTION elements are the values for the SELECT. SELECT
elements don't have a maxlength attribute, either. Basically, even
if the script part of your HTML syntax was correct, which it isn't,
the above still wouldn't work.

Without knowing exactly what you were trying to acheive, I can't
give a definitive answer, but I can point you in the right
direction.

As I already said, what you are expecting from that HTML is *never*
going to happen. It's like specifying an IMG element as the value of
a BUTTON and expecting it to render the image:

<BUTTON value="<IMG src='someImage.gif'>"></BUTTON> [1]

There are two methods of doing what you hope to acheive:

1) Write the entire element using document.write(), concatenating
the date into a fixed string, or;
2) Assign the value to the element at some point after creating it
(when the onload event is fired, for example).

I'll assume below that in your HTML you wanted a drop-down box that
displayed, as it's initial option, the current local date only (not
time).

An example for the first method:

<SELECT name="batchStartDate" size="1">
<SCRIPT type="text/javascript">
// Notice that you forgot to specify the script type in your
// example.

var now = new Date();

document.write(
'<OPTION selected>' + now.getFullYear() + '-'
+ now.getMonth() + '-' + now.getDate() + '<\/OPTION>' );

// Produces the HTML: <OPTION selected>YYYY-M-d</OPTION>
//
// where YYYY is a four letter year
// M is the month (no leading zero)
// d is the day (no leading zero)
</SCRIPT>
</SELECT>
An example for the second method:

<HEAD>
<!-- Set the default script language
for the onload event below -->
<META http-equiv="Content-Script-Type"
content="text/javascript">

<SCRIPT type="text/javascript">
function insertCurrentDate() {
var now = new Date();
var value = now.getFullYear() + '-' + now.getMonth() + '-'
+ now.getDate();
var initial = null;

// Find the OPTION element and replace it's display text and
// value to the current date
if (document.getElementById) {
var initial = document.getElementById('initial');
} else if (document.all) {
var initial = document.all['initial'];
}
if (initial) {
initial.text = value;
initial.value = value;
}
}
</SCRIPT>
...
</HEAD>

<BODY onload="insertCurrentDate()">
...
<SELECT name="batchStartDate" size="1">
<OPTION id="initial" selected>Today</OPTION>
...
</SELECT>

I *seriously* recommend that you refresh your knowledge of HTML and
JavaScript.

Mike
[1] The correct syntax is, of course:

<BUTTON><IMG src="someImage.gif"></BUTTON>

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #3
In article <cI********************@ursa-nb00s0.nbnet.nb.ca>,
be****@islandtelecom.com enlightened us with...
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>
I just want to default the html control to todays date.

Why is this all so painful......maybe time for a career change :(


Because you're trying to set a value to a select element when select
elements have options and selectedIndex, not values. You're also giving
it a maxlength when that is not a property of select elements. Select
elements have options. Options have values.
Choose an option with your script (you'll either need a loop or you'll
need to know the option index to set it), then call the script in the
onLoad of the body. Note that this will muck things up if the user
presses the back button after leaving the page, as the date will be
reset instead of holding on as the user expects. To help this, I check
for a value before resetting it in my stuff.
If this were a text element, you should still set in the script by using
document.formname.elementname.value=d;
not try to call a script like you did above inside the value quotes.
That works fine with server-side <%= val %> type statements, but I've
never seen it used client-side with a script block.

--
--
~kaeli~
Is it possible to be totally partial?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:cI********************@ursa-nb00s0.nbnet.nb.ca...
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>
I just want to default the html control to todays date.

Why is this all so painful......maybe time for a career change :(


1) size="1" does nothing useful

2) maxlength="50" does nothing

3) SELECT does not support "value="

4) You cannot assign a form value with JavScript in that manner.

5) Are you sure you want a SELECT?

Perhpas you want; (watch for word-wrap):

<script language="javascript" type="text/javascript">
<!--
var html = "<input type='text' name='BatchStartDate' size='10'
maxlength='10' value='";
var when = new Date();
html += when.getMonth()+1 + "/";
html += when.getDate() + "/";
html += when.getFullYear() + "'>";
document.write(html);
// -->
</script>
Note that the month and day will have leading zeroes suppressed; thus New
Year's Day will be shown as "1/1/2004".
Jul 20 '05 #5
Sorry guys, you are right, I don't want a select, cut and paste error. I
wanted the following:

function SetDefaultDate() {
rightnow = new Date("Month dd, yyyy");
return rightnow;
}

<TD align=left> <input type="text" name="batchStartDate" size="20"
maxlength="50" value="SetDefaultDate()">
However it still does not work, sorry for the confusion

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:trjEb.143715$_M.713535@attbi_s54...
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:cI********************@ursa-nb00s0.nbnet.nb.ca...
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>
I just want to default the html control to todays date.

Why is this all so painful......maybe time for a career change :(


1) size="1" does nothing useful

2) maxlength="50" does nothing

3) SELECT does not support "value="

4) You cannot assign a form value with JavScript in that manner.

5) Are you sure you want a SELECT?

Perhpas you want; (watch for word-wrap):

<script language="javascript" type="text/javascript">
<!--
var html = "<input type='text' name='BatchStartDate' size='10'
maxlength='10' value='";
var when = new Date();
html += when.getMonth()+1 + "/";
html += when.getDate() + "/";
html += when.getFullYear() + "'>";
document.write(html);
// -->
</script>
Note that the month and day will have leading zeroes suppressed; thus New
Year's Day will be shown as "1/1/2004".

Jul 20 '05 #6
Nope :)
"@SM" <st**************@wanadoo.fr> wrote in message
news:3F***************@wanadoo.fr...


Brent Eamer a ecrit :

function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">


may be ... ?

value="<SCRIPT>document.write(SetDefaultDate())</SCRIPT>">
</TD>
</TR>

Jul 20 '05 #7
Sorry to be picky but...

"now.getMonth()" returns 0 to 11 (not 1 to 12).

You example will display the previous month.
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:Xn*******************************@193.38.113. 46...
Brent Eamer wrote on 18 Dec 2003 at Thu, 18 Dec 2003 13:11:36 GMT:
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1"
maxlength="50" value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>


I was going to say: "That SCRIPT block is being interpreted as it's
supposed to be in that context: a CDATA (string) value." But when I
checked the HTML standard (to check that value attributes contain
CDATA), I realised that SELECT elements don't have value attributes;
the selected OPTION elements are the values for the SELECT. SELECT
elements don't have a maxlength attribute, either. Basically, even
if the script part of your HTML syntax was correct, which it isn't,
the above still wouldn't work.

Without knowing exactly what you were trying to acheive, I can't
give a definitive answer, but I can point you in the right
direction.

As I already said, what you are expecting from that HTML is *never*
going to happen. It's like specifying an IMG element as the value of
a BUTTON and expecting it to render the image:

<BUTTON value="<IMG src='someImage.gif'>"></BUTTON> [1]

There are two methods of doing what you hope to acheive:

1) Write the entire element using document.write(), concatenating
the date into a fixed string, or;
2) Assign the value to the element at some point after creating it
(when the onload event is fired, for example).

I'll assume below that in your HTML you wanted a drop-down box that
displayed, as it's initial option, the current local date only (not
time).

An example for the first method:

<SELECT name="batchStartDate" size="1">
<SCRIPT type="text/javascript">
// Notice that you forgot to specify the script type in your
// example.

var now = new Date();

document.write(
'<OPTION selected>' + now.getFullYear() + '-'
+ now.getMonth() + '-' + now.getDate() + '<\/OPTION>' );

// Produces the HTML: <OPTION selected>YYYY-M-d</OPTION>
//
// where YYYY is a four letter year
// M is the month (no leading zero)
// d is the day (no leading zero)
</SCRIPT>
</SELECT>
An example for the second method:

<HEAD>
<!-- Set the default script language
for the onload event below -->
<META http-equiv="Content-Script-Type"
content="text/javascript">

<SCRIPT type="text/javascript">
function insertCurrentDate() {
var now = new Date();
var value = now.getFullYear() + '-' + now.getMonth() + '-'
+ now.getDate();
var initial = null;

// Find the OPTION element and replace it's display text and
// value to the current date
if (document.getElementById) {
var initial = document.getElementById('initial');
} else if (document.all) {
var initial = document.all['initial'];
}
if (initial) {
initial.text = value;
initial.value = value;
}
}
</SCRIPT>
...
</HEAD>

<BODY onload="insertCurrentDate()">
...
<SELECT name="batchStartDate" size="1">
<OPTION id="initial" selected>Today</OPTION>
...
</SELECT>

I *seriously* recommend that you refresh your knowledge of HTML and
JavaScript.

Mike
[1] The correct syntax is, of course:

<BUTTON><IMG src="someImage.gif"></BUTTON>

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")

Jul 20 '05 #8
Refresh?
I'm fairly new to this stuff :)

I'm an old Oracle PL/SQL programmer, and boy some of this stuff can really
trip you up. Trying to upgrade my skills during my unemployment

Thanks

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:Xn*******************************@193.38.113. 46...
Brent Eamer wrote on 18 Dec 2003 at Thu, 18 Dec 2003 13:11:36 GMT:
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1"
maxlength="50" value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>


I was going to say: "That SCRIPT block is being interpreted as it's
supposed to be in that context: a CDATA (string) value." But when I
checked the HTML standard (to check that value attributes contain
CDATA), I realised that SELECT elements don't have value attributes;
the selected OPTION elements are the values for the SELECT. SELECT
elements don't have a maxlength attribute, either. Basically, even
if the script part of your HTML syntax was correct, which it isn't,
the above still wouldn't work.

Without knowing exactly what you were trying to acheive, I can't
give a definitive answer, but I can point you in the right
direction.

As I already said, what you are expecting from that HTML is *never*
going to happen. It's like specifying an IMG element as the value of
a BUTTON and expecting it to render the image:

<BUTTON value="<IMG src='someImage.gif'>"></BUTTON> [1]

There are two methods of doing what you hope to acheive:

1) Write the entire element using document.write(), concatenating
the date into a fixed string, or;
2) Assign the value to the element at some point after creating it
(when the onload event is fired, for example).

I'll assume below that in your HTML you wanted a drop-down box that
displayed, as it's initial option, the current local date only (not
time).

An example for the first method:

<SELECT name="batchStartDate" size="1">
<SCRIPT type="text/javascript">
// Notice that you forgot to specify the script type in your
// example.

var now = new Date();

document.write(
'<OPTION selected>' + now.getFullYear() + '-'
+ now.getMonth() + '-' + now.getDate() + '<\/OPTION>' );

// Produces the HTML: <OPTION selected>YYYY-M-d</OPTION>
//
// where YYYY is a four letter year
// M is the month (no leading zero)
// d is the day (no leading zero)
</SCRIPT>
</SELECT>
An example for the second method:

<HEAD>
<!-- Set the default script language
for the onload event below -->
<META http-equiv="Content-Script-Type"
content="text/javascript">

<SCRIPT type="text/javascript">
function insertCurrentDate() {
var now = new Date();
var value = now.getFullYear() + '-' + now.getMonth() + '-'
+ now.getDate();
var initial = null;

// Find the OPTION element and replace it's display text and
// value to the current date
if (document.getElementById) {
var initial = document.getElementById('initial');
} else if (document.all) {
var initial = document.all['initial'];
}
if (initial) {
initial.text = value;
initial.value = value;
}
}
</SCRIPT>
...
</HEAD>

<BODY onload="insertCurrentDate()">
...
<SELECT name="batchStartDate" size="1">
<OPTION id="initial" selected>Today</OPTION>
...
</SELECT>

I *seriously* recommend that you refresh your knowledge of HTML and
JavaScript.

Mike
[1] The correct syntax is, of course:

<BUTTON><IMG src="someImage.gif"></BUTTON>

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")

Jul 20 '05 #9
Did you see the code at the bottom of my response?

"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:pz********************@ursa-nb00s0.nbnet.nb.ca...
Sorry guys, you are right, I don't want a select, cut and paste error. I
wanted the following:

function SetDefaultDate() {
rightnow = new Date("Month dd, yyyy");
return rightnow;
}

<TD align=left> <input type="text" name="batchStartDate" size="20"
maxlength="50" value="SetDefaultDate()">
However it still does not work, sorry for the confusion

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:trjEb.143715$_M.713535@attbi_s54...
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:cI********************@ursa-nb00s0.nbnet.nb.ca...
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>
I just want to default the html control to todays date.

Why is this all so painful......maybe time for a career change :(


1) size="1" does nothing useful

2) maxlength="50" does nothing

3) SELECT does not support "value="

4) You cannot assign a form value with JavScript in that manner.

5) Are you sure you want a SELECT?

Perhpas you want; (watch for word-wrap):

<script language="javascript" type="text/javascript">
<!--
var html = "<input type='text' name='BatchStartDate' size='10'
maxlength='10' value='";
var when = new Date();
html += when.getMonth()+1 + "/";
html += when.getDate() + "/";
html += when.getFullYear() + "'>";
document.write(html);
// -->
</script>
Note that the month and day will have leading zeroes suppressed; thus New Year's Day will be shown as "1/1/2004".


Jul 20 '05 #10
Yes

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:iVjEb.423032$ao4.1356533@attbi_s51...
Did you see the code at the bottom of my response?

"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:pz********************@ursa-nb00s0.nbnet.nb.ca...
Sorry guys, you are right, I don't want a select, cut and paste error. I
wanted the following:

function SetDefaultDate() {
rightnow = new Date("Month dd, yyyy");
return rightnow;
}

<TD align=left> <input type="text" name="batchStartDate" size="20"
maxlength="50" value="SetDefaultDate()">
However it still does not work, sorry for the confusion

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:trjEb.143715$_M.713535@attbi_s54...
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:cI********************@ursa-nb00s0.nbnet.nb.ca...
> function SetDefaultDate() {
> d = new Date();
> return d;
> }
> .......
> <TD align=left> Start Date: </TD>
> <TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50" > value="<SCRIPT>SetDefaultDate()</SCRIPT>">
> </TD>
> </TR>
>
>
> I just want to default the html control to todays date.
>
> Why is this all so painful......maybe time for a career change :(

1) size="1" does nothing useful

2) maxlength="50" does nothing

3) SELECT does not support "value="

4) You cannot assign a form value with JavScript in that manner.

5) Are you sure you want a SELECT?

Perhpas you want; (watch for word-wrap):

<script language="javascript" type="text/javascript">
<!--
var html = "<input type='text' name='BatchStartDate' size='10'
maxlength='10' value='";
var when = new Date();
html += when.getMonth()+1 + "/";
html += when.getDate() + "/";
html += when.getFullYear() + "'>";
document.write(html);
// -->
</script>
Note that the month and day will have leading zeroes suppressed; thus New Year's Day will be shown as "1/1/2004".



Jul 20 '05 #11
I found the value='";
Interesting, why the ;
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:iW********************@ursa-nb00s0.nbnet.nb.ca...
Yes

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:iVjEb.423032$ao4.1356533@attbi_s51...
Did you see the code at the bottom of my response?

"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:pz********************@ursa-nb00s0.nbnet.nb.ca...
Sorry guys, you are right, I don't want a select, cut and paste error. I wanted the following:

function SetDefaultDate() {
rightnow = new Date("Month dd, yyyy");
return rightnow;
}

<TD align=left> <input type="text" name="batchStartDate" size="20"
maxlength="50" value="SetDefaultDate()">
However it still does not work, sorry for the confusion

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:trjEb.143715$_M.713535@attbi_s54...
> "Brent Eamer" <be****@islandtelecom.com> wrote in message
> news:cI********************@ursa-nb00s0.nbnet.nb.ca...
> > function SetDefaultDate() {
> > d = new Date();
> > return d;
> > }
> > .......
> > <TD align=left> Start Date: </TD>
> > <TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50" > > value="<SCRIPT>SetDefaultDate()</SCRIPT>">
> > </TD>
> > </TR>
> >
> >
> > I just want to default the html control to todays date.
> >
> > Why is this all so painful......maybe time for a career change :(
>
> 1) size="1" does nothing useful
>
> 2) maxlength="50" does nothing
>
> 3) SELECT does not support "value="
>
> 4) You cannot assign a form value with JavScript in that manner.
>
> 5) Are you sure you want a SELECT?
>
>
>
> Perhpas you want; (watch for word-wrap):
>
> <script language="javascript" type="text/javascript">
> <!--
> var html = "<input type='text' name='BatchStartDate' size='10'
> maxlength='10' value='";
> var when = new Date();
> html += when.getMonth()+1 + "/";
> html += when.getDate() + "/";
> html += when.getFullYear() + "'>";
> document.write(html);
> // -->
> </script>
>
>
> Note that the month and day will have leading zeroes suppressed;
thus New
> Year's Day will be shown as "1/1/2004".
>
>



Jul 20 '05 #12
@SM wrote on 18 Dec 2003 at Thu, 18 Dec 2003 14:57:22 GMT:
may be ... ?

value="<SCRIPT>document.write(SetDefaultDate())</SCRIPT>">


Umm, no. I think you need to review your knowledge of HTML, too.

See my other post.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #13
The variable "html" is be "constructed"; the "document.write()" statement
will display:

<input type='text' name='BatchStartDate' size='10' maxlength='10'
value='12/18/2003'>";
Just cut-and-paste the code into a Web page and try it -- it works as-is.
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:5X********************@ursa-nb00s0.nbnet.nb.ca...
I found the value='";
Interesting, why the ;
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:iW********************@ursa-nb00s0.nbnet.nb.ca...
Yes

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:iVjEb.423032$ao4.1356533@attbi_s51...
Did you see the code at the bottom of my response?

"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:pz********************@ursa-nb00s0.nbnet.nb.ca...
> Sorry guys, you are right, I don't want a select, cut and paste error.
I
> wanted the following:
>
> function SetDefaultDate() {
> rightnow = new Date("Month dd, yyyy");
> return rightnow;
> }
>
> <TD align=left> <input type="text" name="batchStartDate" size="20"
> maxlength="50" value="SetDefaultDate()">
>
>
> However it still does not work, sorry for the confusion
>
> "McKirahan" <Ne**@McKirahan.com> wrote in message
> news:trjEb.143715$_M.713535@attbi_s54...
> > "Brent Eamer" <be****@islandtelecom.com> wrote in message
> > news:cI********************@ursa-nb00s0.nbnet.nb.ca...
> > > function SetDefaultDate() {
> > > d = new Date();
> > > return d;
> > > }
> > > .......
> > > <TD align=left> Start Date: </TD>
> > > <TD align=left> <SELECT name="batchStartDate" size="1"

maxlength="50"
> > > value="<SCRIPT>SetDefaultDate()</SCRIPT>">
> > > </TD>
> > > </TR>
> > >
> > >
> > > I just want to default the html control to todays date.
> > >
> > > Why is this all so painful......maybe time for a career change
:( > >
> > 1) size="1" does nothing useful
> >
> > 2) maxlength="50" does nothing
> >
> > 3) SELECT does not support "value="
> >
> > 4) You cannot assign a form value with JavScript in that manner. > >
> > 5) Are you sure you want a SELECT?
> >
> >
> >
> > Perhpas you want; (watch for word-wrap):
> >
> > <script language="javascript" type="text/javascript">
> > <!--
> > var html = "<input type='text' name='BatchStartDate' size='10'
> > maxlength='10' value='";
> > var when = new Date();
> > html += when.getMonth()+1 + "/";
> > html += when.getDate() + "/";
> > html += when.getFullYear() + "'>";
> > document.write(html);
> > // -->
> > </script>
> >
> >
> > Note that the month and day will have leading zeroes suppressed;

thus New
> > Year's Day will be shown as "1/1/2004".
> >
> >
>
>



Jul 20 '05 #14
Sorry, "is be" should have been "is being".
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:ykkEb.144172$_M.714547@attbi_s54...
The variable "html" is be "constructed"; the "document.write()" statement
will display:

<input type='text' name='BatchStartDate' size='10' maxlength='10'
value='12/18/2003'>";
Just cut-and-paste the code into a Web page and try it -- it works as-is.
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:5X********************@ursa-nb00s0.nbnet.nb.ca...
I found the value='";
Interesting, why the ;
"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:iW********************@ursa-nb00s0.nbnet.nb.ca...
Yes

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:iVjEb.423032$ao4.1356533@attbi_s51...
> Did you see the code at the bottom of my response?
>
> "Brent Eamer" <be****@islandtelecom.com> wrote in message
> news:pz********************@ursa-nb00s0.nbnet.nb.ca...
> > Sorry guys, you are right, I don't want a select, cut and paste error.
I
> > wanted the following:
> >
> > function SetDefaultDate() {
> > rightnow = new Date("Month dd, yyyy");
> > return rightnow;
> > }
> >
> > <TD align=left> <input type="text" name="batchStartDate" size="20"
> > maxlength="50" value="SetDefaultDate()">
> >
> >
> > However it still does not work, sorry for the confusion
> >
> > "McKirahan" <Ne**@McKirahan.com> wrote in message
> > news:trjEb.143715$_M.713535@attbi_s54...
> > > "Brent Eamer" <be****@islandtelecom.com> wrote in message
> > > news:cI********************@ursa-nb00s0.nbnet.nb.ca...
> > > > function SetDefaultDate() {
> > > > d = new Date();
> > > > return d;
> > > > }
> > > > .......
> > > > <TD align=left> Start Date: </TD>
> > > > <TD align=left> <SELECT name="batchStartDate" size="1"
maxlength="50"
> > > > value="<SCRIPT>SetDefaultDate()</SCRIPT>">
> > > > </TD>
> > > > </TR>
> > > >
> > > >
> > > > I just want to default the html control to todays date.
> > > >
> > > > Why is this all so painful......maybe time for a career change

:( > > >
> > > 1) size="1" does nothing useful
> > >
> > > 2) maxlength="50" does nothing
> > >
> > > 3) SELECT does not support "value="
> > >
> > > 4) You cannot assign a form value with JavScript in that manner. > > >
> > > 5) Are you sure you want a SELECT?
> > >
> > >
> > >
> > > Perhpas you want; (watch for word-wrap):
> > >
> > > <script language="javascript" type="text/javascript">
> > > <!--
> > > var html = "<input type='text' name='BatchStartDate' size='10'
> > > maxlength='10' value='";
> > > var when = new Date();
> > > html += when.getMonth()+1 + "/";
> > > html += when.getDate() + "/";
> > > html += when.getFullYear() + "'>";
> > > document.write(html);
> > > // -->
> > > </script>
> > >
> > >
> > > Note that the month and day will have leading zeroes suppressed;

thus
> New
> > > Year's Day will be shown as "1/1/2004".
> > >
> > >
> >
> >
>
>



Jul 20 '05 #15
Brent Eamer wrote:
I found the value='";
Interesting, why the ;


All JavaScript lines should end in semicolons.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 20 '05 #16
In article <MP************************@news.pop4.net>, Chris Smith
<cd*****@twu.net> writes:
Brent Eamer wrote:
I found the value='";
Interesting, why the ;


All JavaScript lines should end in semicolons.


Are you positive about that? semicolons at the ends of some lines will break
the code. Consider:

for (i=0;i<31;i++);
{;
alert(i);
};

I use that format when nesting for loops (and if statements) so I can keep
track of opened and closed { }. The semicolon at the end of the for statement
utterly breaks it. Without the ;, you get 31 alerts, starting from 0 to 30, as
it should be. With the semicolon there, you get one alert (31), which is not
what the code is intended to do.
--
Randy
Jul 20 '05 #17
> >All JavaScript lines should end in semicolons.
Are you positive about that? semicolons at the ends of some lines will break
the code. Consider:

for (i=0;i<31;i++);
{;
alert(i);
};

I use that format when nesting for loops (and if statements) so I can keep
track of opened and closed { }. The semicolon at the end of the for statement
utterly breaks it. Without the ;, you get 31 alerts, starting from 0 to 30, as
it should be. With the semicolon there, you get one alert (31), which is not
what the code is intended to do.


You are correct. Brent should have said that statements should end with
semicolons. JSLINT can help you place them correctly. You also demonstrated why
if statements should always be used with blocks, and why blocks should not be
used alone. JSLINT checks for those, too.

http://www.crockford.com/javascript/lint.html

Jul 20 '05 #18
McKirahan wrote on 18 Dec 2003 at Thu, 18 Dec 2003 15:22:10 GMT:
Sorry to be picky but...

"now.getMonth()" returns 0 to 11 (not 1 to 12).

You example will display the previous month.


Very good point! I always forget that...

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #19
Douglas Crockford wrote:
You are correct. Brent should have said that statements should end with
semicolons. JSLINT can help you place them correctly. You also demonstrated why
if statements should always be used with blocks, and why blocks should not be
used alone. JSLINT checks for those, too.


Actually, it was me (not Brent) that said lines when I should have said
statements.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 20 '05 #20
<TD align=left>
<SELECT name="batchStartDate" size="1" maxlength="50">
<OPTION><SCRIPT>document.write(GetDefaultDate()) </SCRIPT>
</SELECT>
</TD>

"Brent Eamer" <be****@islandtelecom.com> wrote in message
news:cI********************@ursa-nb00s0.nbnet.nb.ca...
function SetDefaultDate() {
d = new Date();
return d;
}
.......
<TD align=left> Start Date: </TD>
<TD align=left> <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>">
</TD>
</TR>
I just want to default the html control to todays date.

Why is this all so painful......maybe time for a career change :(

Jul 20 '05 #21
McKirahan wrote on 18 Dec 2003 at Thu, 18 Dec 2003 16:14:43 GMT:
Sorry, "is be" should have been "is being".


<snipped vast amounts of unneeded quoting>

Please, will you both:

1) Not top-post (place your comments under or amongst quoted text)
2) Trim quoted material to only what is relavant to your post

I'm not trying to be awkward; these practices are part of
established Usenet etiquette.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #22
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:Xn*******************************@193.38.113. 46...
McKirahan wrote on 18 Dec 2003 at Thu, 18 Dec 2003 16:14:43 GMT:
Sorry, "is be" should have been "is being".


<snipped vast amounts of unneeded quoting>

Please, will you both:

1) Not top-post (place your comments under or amongst quoted text)
2) Trim quoted material to only what is relavant to your post

I'm not trying to be awkward; these practices are part of
established Usenet etiquette.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")

Will do. Thanks for the heads up.

I did not know that one should:
"Trim quoted material to only what is relavant to your post".

P.S. It's spelled "relevant".
Jul 20 '05 #23
In article <cgqEb.82049$8y1.287990@attbi_s52>, "McKirahan" <Ne**@McKirahan.com>
writes:
Will do. Thanks for the heads up.

I did not know that one should:
"Trim quoted material to only what is relavant to your post".

P.S. It's spelled "relevant".


Is this alt.correct.spelling or is it comp.lang.javascript where most of the
posters (regulars), have English as a second (or third/fourth) language? Thats
being very very pedantic to me.
--
Randy
Jul 20 '05 #24
McKirahan wrote on 18 Dec 2003 at Thu, 18 Dec 2003 22:56:08 GMT:
P.S. It's spelled "relevant".


I didn't think it looked right, but I wasn't in the mood to check my
dictionary.

Besides, I'm tired. Leave me alone. :P Hehe

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #25
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:cgqEb.82049$8y1.287990@attbi_s52...
<snip>
--
Michael Winter
<snip> Will do. Thanks for the heads up.

I did not know that one should:
"Trim quoted material to only what is relavant to your post".

<snip>

For future reference, other people's signatures, the part separated from
the body of a post with "-- " (dash-dash-space), is almost never
relevant to a response and so a good candidate for trimming.

Richard.
Jul 20 '05 #26
McKirahan wrote:
"Brent Eamer" <be****@islandtelecom.com> wrote:
[...] <SELECT name="batchStartDate" size="1" maxlength="50"
value="<SCRIPT>SetDefaultDate()</SCRIPT>"> [...]

[...]


1) size="1" does nothing useful


False. size="1" allows only one option to be visible at the same time.
Recent graphical UAs render such a `select' element as dropdown box.
PointedEars
Jul 20 '05 #27
JRS: In article <20***************************@mb-m25.aol.com>, seen in
news:comp.lang.javascript, HikksNotAtHome <hi************@aol.com>
posted at Thu, 18 Dec 2003 23:37:39 :-
In article <cgqEb.82049$8y1.287990@attbi_s52>, "McKirahan" <Ne**@McKirahan.com>
writes:
Will do. Thanks for the heads up.

I did not know that one should:
"Trim quoted material to only what is relavant to your post".

P.S. It's spelled "relevant".


Is this alt.correct.spelling or is it comp.lang.javascript where most of the
posters (regulars), have English as a second (or third/fourth) language? Thats
being very very pedantic to me.

Most of the regulars who have English as a subsequent language are in
fact rather good at it, and it would be a pity to teach them mistakes.

Moreover, when using a search tool, it helps if one knows how the word
was spelt.

Careful spelling should be encouraged; it is worth a sentence from time
to time, though generally not a dedicated article.

While on the subject of usage : the OP should have chosen an informative
subject line, and his headers use the non-standard AST (clueless news-
service in New Brunswick?).

--
© 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.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 20 '05 #28
@SM


Brent Eamer a ecrit :

Sorry guys, you are right, I don't want a select, cut and paste error. I
wanted the following:

function SetDefaultDate() {
rightnow = new Date("Month dd, yyyy");
return rightnow;
}

<TD align=left> <input type="text" name="batchStartDate" size="20"
maxlength="50" value="SetDefaultDate()">

However it still does not work, sorry for the confusion


try that :

<TD align=left> <input type="text" name="batchStartDate" size="20"
maxlength="50" value=""> <script type="text/javascript"><!--
this.form.batchStartDate.value = SetDefaultDate();
// --></script>
Jul 20 '05 #29

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

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
1
by: Sarah | last post by:
Hello. I am using Microsoft.Office.Interop.Excel in a C# .NET project. I want to open an Excel application with a specific file name. I am currently opening it with this code: ...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
10
by: Nathaniel Branden | last post by:
Hello. This isn't really an Access question. I just want to know whether Tony Toews is retarded. In that vain, I have pasted down his last thirty or so posts for someone out there to respond. ...
3
by: Rod | last post by:
In Dino Esposito's book, "Programming Microsoft ASP.NET", there is a chapter titled, "ASP.NET State Management". There is a section in there discussing session state sometimes going away. He...
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
13
by: Kyle Adams | last post by:
I don't know where is the right place to ask this so I will start here. Can someone explain to me what these represent? I think they all have to do with the middleware level, but I really don't...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
7
by: Giancarlo Bassi | last post by:
Please, what are here the 11 include files (found over the internet)? */mozzarella.c /* #include #include #include #include #include #include
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.