By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

adapting code

P: n/a
I have a need to insert a changing text with the .jpg into this code. Can
you advise, please? I appreciate this newsgroup, Dick Ross

<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
// End -->
</script>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.63 KB -->
Jan 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"ross" <ro***@everestkc.net> wrote in message
news:cb***************************@EVERESTKC.NET.. .
I have a need to insert a changing text with the .jpg into this code. Can
you advise, please? I appreciate this newsgroup, Dick Ross

<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
// End -->
</script>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.63 KB -->


Is this what your looking for?

<script type="text/javascript">
var now = new Date();
var day = now.getDay();
var arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");
var artxt = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");

document.write("<img src='" + arday[day] + "'>");
document.write("<br>Today is " + artxt[day]);
</script>
Jan 24 '06 #2

P: n/a
ross wrote:
I have a need to insert a changing text with the .jpg into this code. Can
you advise, please? I appreciate this newsgroup, Dick Ross
<SCRIPT LANGUAGE="JavaScript">
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
</script>

<script type="text/javascript">
day = new Date().getDay();
arday = ["sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg"];
artext = ["sunday text", "monday text", "tuesday text",
"wednesday text", "thursday text", "friday text", "saturday text"];
document.write(
"<img src='" + arday[day] + "'>"+"<BR>"+artext[day]);
</script>

Mick

Jan 24 '06 #3

P: n/a
I will give it a try. I am very inept at javascript, so I really appreciate
your help,
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:_a******************************@comcast.com. ..
"ross" <ro***@everestkc.net> wrote in message
news:cb***************************@EVERESTKC.NET.. .
I have a need to insert a changing text with the .jpg into this code. Can
you advise, please? I appreciate this newsgroup, Dick Ross

<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
// End -->
</script>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 0.63 KB -->


Is this what your looking for?

<script type="text/javascript">
var now = new Date();
var day = now.getDay();
var arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");
var artxt = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");

document.write("<img src='" + arday[day] + "'>");
document.write("<br>Today is " + artxt[day]);
</script>

Jan 24 '06 #4

P: n/a
McKirahan wrote:
<script type="text/javascript">
var now = new Date();
var day = now.getDay();
var arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");
var artxt = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");
Since the names of files and weekdays are this similar, `artxt' is not
necessary.
document.write("<img src='" + arday[day] + "'>");
The `img' element requires the `alt' attribute to provide for graceful
degradation.
document.write("<br>Today is " + artxt[day]);
Consecutive calls of document.write() are inefficient and error-prone.
</script>


<script type="text/javascript">
var
now = new Date(),
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg"),
wkday = arday[now.getDay()],
txt = wkday.charAt(0).toUpperCase()
+ wkday.substr(1).replace(".jpg", "");

document.write(
"<img src='" + wkday + "' alt='" + txt + "'>"
+ "<br>Today is " + txt);
</script>

It should be noted that the restrictions on correctness of client-side dates
apply.
PointedEars
Jan 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.