473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can some1 help with my kink is java

the assignment was to make list of 7 days starting with curent only
that red was supposed to be in red. ive creted code only problem is its
automatically makes 1st day red, which would be ok if day is sunday but
6 days out of week assignment will be wrong, heres code.

"<html><title>M arks JS</title>

<body> <font size = "4">

<script language = "JavaScript ">

<!--Hide from non-Javascript browsers

var Today = new Date() ;

var DayNumber = Today.getDay() ;

var Day;

var weekday=new Array(14);

weekday[0]="Sunday";

weekday[1]="Monday";

weekday[2]="Tuesday";

weekday[3]="Wednesday" ;

weekday[4]="Thursday";

weekday[5]="Friday";

weekday[6]="Saturday";

weekday[7]="Sunday";

weekday[8]="Monday";

weekday[9]="Tuesday";

weekday[10]="Wednesday" ;

weekday[11]="Thursday";

weekday[12]="Friday";

weekday[13]="Saturday";

var color=new Array(14);

color[0]="red";

color[1]="blue";

color[2]="green";

color[3]="orange";

color[4]="black";

color[5]="yellow";

color[6]="gray";

color[7]="red";

color[8]="Monday";

color[9]="blue";

color[10]="green";

color[11]="orange";

color[12]="black";

color[13]="yellow";

i = Today.getDay();

for(i=0;i<7;i++ )

{

DayNumber = Today.getDay() +i;

document.write( "<font color = " + color + " >"+"The day is " +
weekday[DayNumber] + "<br/></font>") ;

}

//Stop hiding -->

</script></font></table></body></html>"

Apr 9 '06 #1
12 1548

<ma******@gmail .com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
the assignment was to make list of 7 days starting with curent only
that red was supposed to be in red. ive creted code only problem is its
automatically makes 1st day red, which would be ok if day is sunday but
6 days out of week assignment will be wrong, heres code.

**snip** document.write( "<font color = " + color + " >"+"The day is " +
weekday[DayNumber] + "<br/></font>") ;


in your code listed above, if you change the first line to:
document.write( "<font color = " + color[DayNumber] + " >"+"The day is " +
(Adding an index in square braces after the array variable named color)
Your output will (probably) do what you are expecting.
You have other errors and some deprecated tags and attributes, but that
little change will make it work.
Apr 9 '06 #2
omg, you are teh greatest it worked, i tested by changing my schedule.

thx.

i have a html job i need done you got time/intrested? im paying

Apr 10 '06 #3
<qu*******@gmai l.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
omg, you are teh greatest it worked, i tested by changing my schedule.

thx.

i have a html job i need done you got time/intrested? im paying


But I am not the greatest -( yet). I'll be a student for the next 20 years.
I wish I was a teenager again - that's when I knew everything.
and no, but thanks - about the job.
IMO, the most helpful of posters on this group are Richard Cornford and one
called RobG.

Good luck on your studies. And if you do your own work, you'll learn more.
Apr 10 '06 #4
JRS: In article <11************ **********@u72g 2000cwu.googleg roups.com>
, dated Sun, 9 Apr 2006 14:47:20 remote, seen in news:comp.lang. javascript,
ma******@gmail. com posted :
the assignment was to make list of 7 days starting with curent only
that red was supposed to be in red. ive creted code only problem is its
automaticall y makes 1st day red, which would be ok if day is sunday but
6 days out of week assignment will be wrong, heres code.


But red is always red. Your specification is unclear. Your subject line
is meaningless.

for ( D = new Date(), k = -7 ; k++ ; D.setDate(D.get Date()+1) )
document.writel n(D.toString(). fontcolor(D.get Day()?"blue":"r ed"), "<br>")

No doubt if you had been paying attention to your class instruction you
would have been able to do the job in more or less the manner that you
attempted. I've therefore done it in a manner which might, by making you
think, teach you an equivalent amount. Don't expect your instructor to
accept it as your own work.

--
© 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.
Apr 10 '06 #5

"Dr John Stockton" <jr*@merlyn.dem on.co.uk> wrote in message
news:ee******** ******@merlyn.d emon.co.uk...
JRS: In article <11************ **********@u72g 2000cwu.googleg roups.com>
, dated Sun, 9 Apr 2006 14:47:20 remote, seen in news:comp.lang. javascript,
for ( D = new Date(), k = -7 ; k++ ; D.setDate(D.get Date()+1) )
document.writel n(D.toString(). fontcolor(D.get Day()?"blue":"r ed"),

"<br>")

Some professors would beat you about the head and shoulders for using a
post-increment operator as a boolean test, and for placing (code that should
be in the body of the loop) as the "update-Expression" in the top parens of
the loop, or for using a day number as a boolean test. I'm beginning to see
what they mean about your code. my GOD, man! Have you no shame? hehehe ;-)
You ride the rugged edge of the language specifications (but inside the
bounds ).
Is it no longer "fashionabl e" to try to conform (as much as practical) to
XHTML practices - like using "<br />" ?

Apr 11 '06 #6

"Lee" <RE************ **@cox.net> wrote in message
news:e1******** *@drn.newsguy.c om...
Hal Rosser said:


"Dr John Stockton" <jr*@merlyn.dem on.co.uk> wrote in message
news:ee******* *******@merlyn. demon.co.uk...
JRS: In article <11************ **********@u72g 2000cwu.googleg roups.com> , dated Sun, 9 Apr 2006 14:47:20 remote, seen innews:comp.lang .javascript,

for ( D = new Date(), k = -7 ; k++ ; D.setDate(D.get Date()+1) )
document.writel n(D.toString(). fontcolor(D.get Day()?"blue":"r ed"),

"<br>")

Some professors would beat you about the head and shoulders for using a
post-increment operator as a boolean test, and for placing (code that shouldbe in the body of the loop) as the "update-Expression" in the top parens ofthe loop, or for using a day number as a boolean test.


All completely ridiculous things to be bothered by.
But then, a surprising number of professional "developers " that
I run into these days have a really hard time understanding code.
I'm beginning to see
what they mean about your code. my GOD, man! Have you no shame? hehehe

;-)
The code you're complaining about is essentially "library code".
Efficiency is a higher priority than readability or even
maintainability . It is not intended to be read and understood
by the typical user.


I'm not *complaining* about the code (in this post) - just making some
'jovial' comments.
The posted code is, as you say, efficient and not intended to be read and
understood by the typical user.
Well - there you go! You said it. Does it also follow that this newsgroup is
not intended to be read and understood by the typical user?
:;-)
Hal
Apr 11 '06 #7
Hal Rosser wrote:
Lee wrote:
Hal Rosser said:
<snip> The posted code is, as you say, efficient and not intended
to be read and understood by the typical user. Well - there you go! You said it. Does it also follow that
this newsgroup is not intended to be read and understood
by the typical user? :;-)


It is probably a personal thing but I prefer the 'user' to be thought of
as the person who ends up interacting with the software written, and the
person 'using' the language as the programmer. In which case this group
is definitely not for the typical user (as they couldn't (even
shouldn't) care less about javascript, and probably don't even know what
it is).

But would the implication of what you are saying be that all posted code
should be suitable for novice javascript programmers? That would not be
such a good idea as then the group would never be able to assist people
in getting beyond the novice stage. In reality the code posted to the
group ranges from that suited to beginners to some of the most advanced
javascript written, as it should as that way the group can be
interesting/instructive even for its more long standing contributors.

Ultimately, if someone does not understand some posted code they can
always have a go at formulating a question about it and posting that to
the group in the hope of an explanation. There are people willing to
have a go at explaining code if suitably asked.

Richard.
Apr 11 '06 #8
Hal Rosser wrote:
Dr John Stockton wrote: <snip>
for ( D = new Date(), k = -7 ; k++ ; D.setDate(D.get Date()+1) )
document.writel n(D.toString(). fontcolor(D.get Day()?"blue":"r ed"),
"<br>")


Some professors would beat you about the head and shoulders
for using a post-increment operator as a boolean test, and
for placing (code that should be in the body of the loop)
as the "update-Expression" in the top parens of the loop,
or for using a day number as a boolean test.


In loosely-types javascript all values have implicit trueness so it is
not at all unusual to see values that are known not to be of boolean
type in contexts where other languages would require boolean values.
That is also not undesirable as working with a loosely-typed language
places the onus on the programmer to keep track of the types of values
and appreciate the consequences and implications of any implicit
type-conversion.

This wider concept of trueness, extending beyond the Boolean type, is
evident in the language itself, where, for example, the logical AND and
OR operators do not necessarily result in boolean values, instead the
actual value of the pertinent operand is the result.

So a javascript programmer should be expected to able to see a value in
a context where it would be subject to the application of the internal
ToBoolean function and understand what the possible resulting boolean
values will be. That is just part of the discipline of writing with a
loosely typed language.
I'm beginning to see what they mean about your code. my GOD,
man! Have you no shame? hehehe ;-) You ride the rugged edge
of the language specifications (but inside the bounds ).
The terseness of John's code is if occasionally commented upon, but that
is nowhere near the 'ragged edge' of ECMAScript.
Is it no longer "fashionabl e" to try to conform (as much as
practical) to XHTML practices - like using "<br />" ?


It is a lamentable truth that the average standard of technical
understanding possessed by web developers/designers world-wide is
atrocious. If something becomes 'fashionable' the odds are good that it
did not become fashionable for sound technical reasons.

HTML and XHTML are distinct mark-up languages, and in our context of
browser scripting that distinction is manifest in these two different
mark-up languages resulting in two distinct types of DOM being exposed
to be scripted. And the differences between those two types of DOM (by
specification and in practice) are such that very few non-trivial
scripts will be capable of successfully interacting with both types of
DOM. We have the HTML DOM, with its case insensitivity, historical
shortcut features, preference for setting Element properties directly,
and so on. While the XHTML DOM is case sensitive, rarely implements more
than is explicitly specified, prefers to have Elements defined with the
setAttribute (or setAttributeNS) methods, has an interest in namespaces,
and traditionally omit some features commonly used in HTML DOMs such
as - document.write -. If a document is to be scripted it is quite
important to know which type of DOM is being scripted, and advice on
scripting one DOM is likely to get in the way when scripting the other.

The decision as to which type of DOM a browser creates is based entirely
upon the content-type header sent by the server with the document. If
the content-type is text/html then the browser will interpret the
document as HTML and build an HTML DOM. Only when a browser supports
XHTML, receives as well-formed XHTML document and receives a formally
correct XHTML mime type in the content-type header is an XHTML DOM
created, and those are also the only circumstances under which a
document really is XHTML, regardless of the appearance of its mark-up.

Because IE does not support XHTML, and cannot create an XHTML DOM, in
order for a document that had XHTML-like mark-up to be displayed in IE
it must be sent with a text/html content-type header. IE then interprets
that document as HTML and error-corrects all of the XTHML-like mark-up
back into tag soup HTML. That is, serving documents that superficially
resemble XHTML to be displayed by IE imposes an entire extra
error-correction stage on the client for the document to be interpreted
as the HTML that it would have been without the imposing the illusion of
document. With the additional irony that sending this document in this
way to a browser that does understand XHTML, like Mozilla or Opera, will
still result in its being interpreted as HTML, subject to
error-correction, and an HTML DOM being built for it.

All of this error-correction has implications for the resulting HTML DOM
as error-correction rules are not formally specified and browsers are
observed to behave differently while carrying it out, producing
structurally different HTML DOMs to be scripted.

Finally, there is the formal definition of HTML to be contended with. By
specification - <br / - is a shorthand for - <br></br> - in HTML, and
so - <br /> - is equivalent to - <br>&gt; -; a BR element followed by a
'greater than' symbol. Fortunately for the people following this
'fashion' most browsers do not follow this particualr formal rule and
instead regard it as an error to be corrected in HTML mark-up, though
there is always a chance that there are browsers that take the HTML
specification at its word and there the result will undesirable.

So it is not a question of what may or may not be fashionable. The
technically informed will write HTML mark-up when they want to serve a
document as text/html and script and HTML DOM, and XHTML mark-up when
they want to serve a document as XHTML and script an XHTML DOM. And with
IE not supporting the second option at all the former is the sensible
option when authoring in a commercial context. (The only alternative
being content negotiation, but you cannot content negotiate scripts and
attempting to write scripts that will work with XHTML DOMs and HTML DOMs
is double the effort for no tangible benefits, so not a sensible option
in a commercial context.)

Richard.
Apr 11 '06 #9
Richard Cornford wrote:
<snip>
... without the imposing the illusion of document. ...

<snip>

Should have been: " without the imposing the illusion of XHTML on the
document"

Richard.
Apr 11 '06 #10

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

Similar topics

2
4210
by: Michael | last post by:
Hello I am trying to write a Java-Program which converts a XML-file in a HTML. It should take the Transformation-file from the XML-file itself. Below find a possible XML-file: <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSPY v5 rel. 3 U (http://www.xmlspy.com) by Michael Herren (private) -->
0
2259
by: Phil Powell | last post by:
Ok, I installed ANT, I have c:\ant in my ANT_HOME environment variable, I have c:\ant\bin in my PATH environmental variable, I installed the JAR files for TCL and for Javascript (Rhino)... to no avail!!! The EXACT same error occurs: org/apache/bsf/BSFManager Please Try The Following:
0
3273
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Should I expect to be able to connect to MySQL5.0 alpha with JDBC? When trying to connect I am getting: ** BEGIN NESTED EXCEPTION **
0
2785
by: John | last post by:
We are doing integration with an AS400 running websphere - webservices. When the customer (AS400) calls the .Net webservice the customers java code (every other request or so) throws the following exception. We are both researching the possible cause of this. Any suggestions on the .Net side for resolving this would be helpful. John java.io.IOException: Broken pipe. at java.lang.Throwable.<init>(Throwable.java:195)
0
11695
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting transaction"; We get such errors generally on inserts or updates while applying a
4
1202
by: confusedbigtime | last post by:
Hi there...im new to C programmin and ive gotten a little stuck with precedence of C operators...it wud be great if some1 cud tell me how the compiler goes about solving these kinds of expressions.... i=0; 7||0&&++i; why doesnt the value of i change???
2
1875
by: patrick j | last post by:
Hello I've created this web-site: <http://www.inventoryworks.co.uk> However in IE6 there is a lack of alignment (or if you like, a kink) on the left side of the text just below the image of the clipboard. If you don't see it at first resizing the browser window of IE6 might well make it more obvious.
1
2505
by: phillip3 | last post by:
Hi i have a school project and i need the code to add a timer! can any1 help me with this problem thanks phillip asap
1
1987
by: Skerdi | last post by:
Hi, I want to print a number in a Access Report but in Barcode font. Can anyone tell me how to do it in any vb code or something? I've tried with a EAN13 FONT but my barcode reader cannot read it
0
8448
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
8871
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...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
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,...
1
6198
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
5666
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
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.