adapting code

R

ross

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 -->
 
M

McKirahan

ross said:
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>
 
M

mick white

ross said:
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
 
R

ross

I will give it a try. I am very inept at javascript, so I really appreciate
your help,
McKirahan said:
ross said:
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>
 
T

Thomas 'PointedEars' Lahn

McKirahan said:
<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top