472,354 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Help with the printdate()

Hello,
I am kind of new to this javascript stuff and I am constantly having
problems trying to get my webpage validated. I have the following
<script>printdate();</script> and when I validate it at validator.w3.org I
get a error the attribute given above is required for an element that you've
used, but you have omitted it. For instance, in most HTML and XHTML document
types the "type" attribute is required on the "script" element and the "alt"
attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and
type="text/javascript" for <script>.
Ok, I tried both of these obtions but it always change my fonts to some
different then what I want it. How can I have it so my fonts will not
change. If more info is needed please let me know.
thank you for your help to this matter
Jul 23 '05 #1
7 1761
mike wrote:
Hello,
I am kind of new to this javascript stuff and I am constantly having
problems trying to get my webpage validated. I have the following
<script>printdate();</script> and when I validate it at validator.w3.org I
get a error the attribute given above is required for an element that you've
used, but you have omitted it. For instance, in most HTML and XHTML document
types the "type" attribute is required on the "script" element and the "alt"
attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and
type="text/javascript" for <script>.
Ok, I tried both of these obtions but it always change my fonts to some
different then what I want it. How can I have it so my fonts will not
change. If more info is needed please let me know.
thank you for your help to this matter


<script type="text/javascript"> and <style type="text/css"> should have no
affect on how the fonts appear on your page. Provide a link to two examples that
demonstrate what you are talking about, or two simple examples here. Also note
which browsers you are seeing this behaviour in. If someone can reproduce your
problem, they can help you fix it.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2
Hello,
Thanks for your reply. I attached part of the script that I am having
problems with which someone might be able to help me out with.
<script language="javascript" type="text/javascript">
<!--
function printdate() {
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
months = new Array(12)
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
today = new Date(); day = days[today.getDay() + 1]
month = months[today.getMonth() + 1]
date = today.getDate()
year=today.getYear();
if (year < 2000) year = year + 1900;
document.write ("<font size=1 face='Americana, Arial, Helvetica,
sans-serif' color=003399>" + day +
", " + month + " " + date + ", " + year)
}
More stuff

</script>
<style type="text/css"> <!--
.pviimenudiv td {font-family: "Trebuchet MS", Arial, sans-serif; font-size:
12px}
.pviimenudiv p {font-family: "Trebuchet MS", Arial, sans-serif; font-size:
12px; margin-top: 12px; margin-bottom: 6px}
.pviimenudiv b {font-family: Verdana, Arial, Helvetica, sans-serif;
font-style: normal; color: #666666}
.pviimenudiv a:link {
color: White;
font-family: "Trebuchet MS", Arial, sans-serif;
font-size: 14px;
text-decoration: underline
}
.pviimenudiv a:visited {
color: White;
font-family: "Trebuchet MS", Arial, sans-serif;
font-size: 14px;
text-decoration: underline
}
.pviimenudiv a:hover {
color: Red; font-family: "Trebuchet MS", Arial, sans-serif; font-size:
14px;
text-decoration: underline
}
.pviimenudiv a:active {
color: Red; font-family: "Trebuchet MS", Arial, sans-serif; font-size:
14px;
text-decoration: underline
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000"
onLoad="P7_setMenuMagic1(10,40,10,'p7menubottom',' p7menu1','p7submenu1','p7m
but1','p7menu2','p7submenu2','p7mbut2','p7menu3',' p7submenu3','p7mbut3','p7m
enu4','p7submenu4','p7mbut4','p7menu5','p7submenu5 ','p7mbut5');P7_MM1dwt();I
nitAnim();">
<bgsound src="C:\My Documents\test.mids">
<div id="p7menu1" style="position:absolute; left:20px; top:220px;
width:160px; z-index:106"><a href="javascript:;"
onClick="P7_trigMenuMagic1('p7menu1',1);return false"
onMouseOver="P7_rollCMenu1(event,'p7menu1',0)"
onMouseOut="P7_rollCMenu1(event,'p7menu1',0)"
onFocus="if(this.blur)this.blur()"><img src="butt1.gif" width="160"
height="22" name="p7mbut1" border="0" alt="menu 1"></a></div>
<div id="p7menu2" style="position:absolute; left:20px; top:242px;
width:160px; z-index:107"><a href="javascript:;"
onClick="P7_trigMenuMagic1('p7menu2',1);return false"
onMouseOver="P7_rollCMenu1(event,'p7menu2',0)"
onMouseOut="P7_rollCMenu1(event,'p7menu2',0)"
onFocus="if(this.blur)this.blur()"><img src="butt2.gif" width="160"
height="22" name="p7mbut2" border="0" alt="menu 2"></a></div>
<div id="p7submenu1" class="pviimenudiv" style="position:absolute;
left:200px; top:242px; width:150px; visibility: hidden; z-index:101">
<table width="150" border="0" cellspacing="6" cellpadding="0">
<tr>
<td><a href="index.html">Home Page</a></td>
</tr>
</table>
</div>
<div id="p7submenu2" class="pviimenudiv" style="position:absolute;
left:200px; top:264px; width:150px; visibility: hidden; z-index:102">
<table width="150" border="0" cellspacing="6" cellpadding="0">
<tr>
<td><a href="test_pages/test.html">test</a></td>
</tr>
</table>
</div>
<td valign="top">
<table width=468 border=0 align="center" cellpadding=0 cellspacing=0
style="border: 1px;"><tr><td>
<div id="surfer3" style="position:absolute"><img src="test.gif"
alt="test"></div>
<div id="surfer4" style="position:absolute"><img src="test.gif"
alt="test"></div>
<div id="surfer5" style="position:absolute"><img src="test.gif"
alt="test"></div>
<div id="surfer6" style="position:absolute"><img src="test.gif"
alt="test"></div>
<ilayer name="waves34i"><div id="waves34"><img src="test.gif"
alt="test"></div></ilayer>
</td></tr></table>

<br><hr size=1>
<script>printdate();</script>
"Grant Wagner" <gw*****@agricoreunited.com> wrote in message
news:41***************@agricoreunited.com...
mike wrote:
Hello,
I am kind of new to this javascript stuff and I am constantly having
problems trying to get my webpage validated. I have the following
<script>printdate();</script> and when I validate it at validator.w3.org I get a error the attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and
type="text/javascript" for <script>.
Ok, I tried both of these obtions but it always change my fonts to some
different then what I want it. How can I have it so my fonts will not
change. If more info is needed please let me know.
thank you for your help to this matter
<script type="text/javascript"> and <style type="text/css"> should have no
affect on how the fonts appear on your page. Provide a link to two

examples that demonstrate what you are talking about, or two simple examples here. Also note which browsers you are seeing this behaviour in. If someone can reproduce your problem, they can help you fix it.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3
JRS: In article <uL*******************@newsread1.news.pas.earthlin k.net
, dated Fri, 13 Aug 2004 01:24:42, seen in news:comp.lang.javascript, mike <nogood@?.invalid> posted :

Read the newsgroup FAQ. Responses should go after trimmed quotes.
Thanks for your reply. I attached part of the script that I am having
problems with which someone might be able to help me out with.
<script language="javascript" type="text/javascript">
<!--
function printdate() {
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
Space-wasting. days = ["Sunday", ..., "Saturday"]
months = new Array(12)
Likewise
today = new Date(); day = days[today.getDay() + 1]
month = months[today.getMonth() + 1]
date = today.getDate()
year=today.getYear();
if (year < 2000) year = year + 1900;
Does not always work. See FAQ & via sig.
document.write ("<font size=1 face='Americana, Arial, Helvetica,
sans-serif' color=003399>" + day +
", " + month + " " + date + ", " + year)
Forcing font size in that way may be contrary to the spirit of the DDA.
Hash may be needed before 003399.
That date format is not suitable for Internet use; follow ISO 8601.
... "Grant Wagner" <gw*****@agricoreunited.com> wrote in message
news:
... ...


<FAQENTRY>

IMHO, 2.10 should be Multinationalisation. That is adjustment for
different locales, whereas Internationalisation means using a single
form acceptable everywhere. dependant -> dependent.

It would be a good place to recommend, as an example, internationalising
to ISO 8601.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4
> >function printdate() {
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";


Space-wasting. days = ["Sunday", ..., "Saturday"]
months = new Array(12)


These are not the same.

The OP has "Sunday" in array element 1 where you have it in zero.

The statement days = new Array(7) allocates 7 memory locations
starting with
days[0] to days[6]. Your reference to day[7] works fine because
Javascript dynamically allocates memory for the array elements. You
can also declare the array by doing:
days = new Array()

or

days = [ ]

Also, your statement allocated days to the global variable pool. To
have the variable defined to just the function, do

var days = [ ];

Robet
Jul 23 '05 #5
On 13 Aug 2004 21:34:18 -0700, Robert <rc*******@my-deja.com> wrote:
function printdate() {
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";


Space-wasting. days = ["Sunday", ..., "Saturday"]
months = new Array(12)


These are not the same.

The OP has "Sunday" in array element 1 where you have it in zero.


That's because the OP needlessly converts the ordinal from zero- to
one-based. The simple fix to change:

var day = days[today.getDay() + 1];

to

var day = days[today.getDay()];

Shorter. Simpler. Quicker.

Likewise with month. I feel that Dr Stockton should have mentioned it,
though. Perhaps he thought it obvious.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail
Jul 23 '05 #6
Hello,
Thanks for all your great suggestions but can someone try to help me with
the problem of trying to validate this.
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opscp1pnt8x13kvk@atlantis...
On 13 Aug 2004 21:34:18 -0700, Robert <rc*******@my-deja.com> wrote:
function printdate() {
days = new Array(7)
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";

Space-wasting. days = ["Sunday", ..., "Saturday"]

months = new Array(12)


These are not the same.

The OP has "Sunday" in array element 1 where you have it in zero.


That's because the OP needlessly converts the ordinal from zero- to
one-based. The simple fix to change:

var day = days[today.getDay() + 1];

to

var day = days[today.getDay()];

Shorter. Simpler. Quicker.

Likewise with month. I feel that Dr Stockton should have mentioned it,
though. Perhaps he thought it obvious.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail

Jul 23 '05 #7
"mike" <nogood@.invalid> wrote in message news:<RT***************@newsread2.news.pas.earthli nk.net>...
Hello,
Thanks for all your great suggestions but can someone try to help me with
the problem of trying to validate this.


I have not seen the output from the validator, but the text field is
required in the script tag. Try:

<SCRIPT type="text/javascript">
printdate();
</script>
You provided a rather large code fragment. We cannot copy and paste
it into a file and run it to see what any problems are. Please
provide a link or a working example. The code fragement you provide
is rather large and complex. It includes about everything but the
kitchen sink: styles, div, table, and iframe.

We may have gotten distracted my the complexity of the fragment. You
original post was about some error messages from the W3C verifier.
Could you provide details about what version of the verifier you are
using, the error messages you got, and an exact copy of the file you
used. Could you trim down the file to a small size and give the error
message you see.

This is a JavaScript forum. You have gotten some great people to
respond to your post.

Robert
Jul 23 '05 #8

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

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
3
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time...
1
by: Jamiil | last post by:
This is the first time I am ever using JavaScript, I am not even elocuent in HTML, all I am is someone who has Microsoft/Netscape Webpage developers. What I am trying to say is that I am not an...
8
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.