473,382 Members | 1,480 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,382 software developers and data experts.

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>Marks 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 1529

<ma******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.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*******@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.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**********************@u72g2000cwu.googlegroups .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
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.


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

for ( D = new Date(), k = -7 ; k++ ; D.setDate(D.getDate()+1) )
document.writeln(D.toString().fontcolor(D.getDay() ?"blue":"red"), "<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.com/faq/> JL/RC: FAQ of 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.
Apr 10 '06 #5

"Dr John Stockton" <jr*@merlyn.demon.co.uk> wrote in message
news:ee**************@merlyn.demon.co.uk...
JRS: In article <11**********************@u72g2000cwu.googlegroups .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.getDate()+1) )
document.writeln(D.toString().fontcolor(D.getDay() ?"blue":"red"),

"<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 "fashionable" 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.com...
Hal Rosser said:


"Dr John Stockton" <jr*@merlyn.demon.co.uk> wrote in message
news:ee**************@merlyn.demon.co.uk...
JRS: In article <11**********************@u72g2000cwu.googlegroups .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.getDate()+1) )
document.writeln(D.toString().fontcolor(D.getDay() ?"blue":"red"),

"<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.getDate()+1) )
document.writeln(D.toString().fontcolor(D.getDay() ?"blue":"red"),
"<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 "fashionable" 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
Hal Rosser said on 12/04/2006 7:05 AM AEST:
"Lee" <RE**************@cox.net> wrote in message
news:e1*********@drn.newsguy.com...

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


I does seem a bit contradictory to have an FAQ to answer what are likely
novice questions, and also to have posted in the same page code that is
expected to be used as-is and without regard for comprehension by those
very same novices. However, expanding the code with full comments and
descriptive variable names would likely quadruple its size (or more).

JRS may have a good point that post such code will encourage programmers
to learn how it works, and in learning that way more knowledge will
stick. But on the other hand it will frustrate some who feel it is
unnecessarily cryptic and as a result may turn to DynamicDrive or JSGuru
or other junk sites.

Richards advice is good - try to understand it, and if you have
questions about a specific point, ask here. Those who have made the
effort to understand before asking a question are treated much more
kindly than those who clearly haven't. :-)
--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 11 '06 #11
"Lee" <RE**************@cox.net> wrote in message
news:e1********@drn.newsguy.com...

No, but when somebody asks how to round off, one valid answer is to
point them to a function that does what they want, even if they may
not be expected to understand how it does it.
*** ** That was a different thread ** does not apply here The OP in this
thread left off the array index - and a few other mistakes, but rounding was
not mentioned - (you can blast me on the other thread - and explain FAQ 4.6
to the group)
**** If they ask how to do something of a more general nature, it might
be better to respond with code that sacrifices efficiency for the
sake of accessibility.

***** yay! ** that's been my point on other posts (re: FAQ 4.6)
********** :-)
Hal
Apr 12 '06 #12
JRS: In article <gd*******************@news.optus.net.au>, dated Tue,
11 Apr 2006 23:46:20 remote, seen in news:comp.lang.javascript, RobG
<rg***@iinet.net.au> posted :
I does seem a bit contradictory to have an FAQ to answer what are likely
novice questions, and also to have posted in the same page code that is
expected to be used as-is and without regard for comprehension by those
very same novices. However, expanding the code with full comments and
descriptive variable names would likely quadruple its size (or more).


A FAQ, regularly posted to News, is not meant to be a tutorial; a
tutorial might be posted once, in suitably-sized pieces, to News for
comment, but should not be posted regularly. The heading of FAQ 4.6 is
a question, and the code answers it.

Those who want to understand code such as in 4.6 can always execute it
with pencil and paper. Or they could follow the link provided and see a
newer version embedded in more text.

<FAQENTRY>
Richard, for the next FAQ version, please look at my Web page section
js-round.htm#GC - the present version (which may change ...) has a StrU
with the same algorithm somewhat differently expressed. I provide both
PrfxTo and SpcsTo because I need PrfxTo there and elsewhere, and several
SpcsTo elsewhere - but, for StrU alone, SpcsTo(,) could be replaced with
PrfxTo(,," ").

M & N can in fact each be zero, though then giving a non-preferred
format. Negative is just silly; but, as they'll generally be supplied
as literals, it's generally not worth coding a check.
</FAQENTRY>

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of 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.
Apr 12 '06 #13

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

Similar topics

2
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...
0
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...
0
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?...
0
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...
0
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...
4
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...
2
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...
1
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
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.