Click to See Complete Forum and Search --> : Refreshing text cell.


ngungo
02-09-2003, 06:27 PM
Of course, I am a newbie. I am taking over the web site of the Lemon Grass Restaurant. The owner wants to change few little things but I don't how to do it, although I have an idea.

Click the link below you will see the index.html of the site. It will stay there for 20 seconds, or soon as the title is clicked it then moves to the index2.html. Basically, the index.html has 2 simple parts: a logo and a text field.

http://www.lemongrassrest.com

Before it moves to the index2.html, try to hit F5 to refresh the page, you will see the text field changes. Keep hitting F5, the text keep changing randomly. Looking at the code I can see how he did. Here is the codes (please note the codes in red):


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="description" content="Lemon Grass Restaurant - A beguiling colonial blend of French, Louisiana Creole and Asian flavors... The culinary equivalent of perfect pitch.&quot;">
<meta http-equiv="keywords" content="New Orleans, dining, restaurants, fine, best, Lemon Grass, Vietnamese, catering, banquets, chefs, Louisiana, Big Easy, Crescent City">
<meta http-equiv="Refresh" CONTENT="20;URL=http://www.lemongrassrest.com/index2.html">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<title>Lemon Grass Restaurant, New Orleans</title>
</head>

<body bgcolor="#FFFFFF" text="#1C5A00" link="#800000" vlink="#1C5A00" alink="#FFFFFF">

<p align="center">&nbsp;</p>
<div align="center"><center>

<table border="0" width="428" cellspacing="0" cellpadding="25">
<tr>
<td width="100%" align="center"><a href="index2.html"><img src="images/logoflush.gif"
alt="Explore Lemon Grass, Wine and Dine Experience" border="0" width="428" height="125"></a></td>
</tr>
<tr>
<td width="100%" align="right"><div align="center"><center><table border="0" width="100%">
<tr>
<td width="100%" align="right"><font face="Arial, Helvetica" size="2" color="#3E683F"><script
LANGUAGE="JavaScript">

<!--

//Code by Mark Sottek. Ask before using please. mark@mardicard.com

quotes = new Array(8);

authors = new Array(8);

quotes[0] = "Lemon Grass feels like a respite from what we've come to perceive as the CBD- severe buildings- business suits- handshakes.";
authors[0] = "<I>New Orleans Magazine</I>, September 1999";

quotes[1] = "The space is light and refreshing, dreamy and <br>almost fantastic, much like the food.";
authors[1] = "Faith Dawson, <I>New Orleans Magazine</I>, September 1999";

quotes[2] = "Shrimp dumplings may not come to mind when you're pondering food choices in New Orleans. But chef Minh Bui's Lemon Grass Cafe is such a hit that he's opening a second place, Lemon Grass Restaurant, in the French Quarter.";
authors[2] = "<I>Food & Wine</I> Magazine, May 1999";

quotes[3] = "Friday Evening we try the Lemon Grass Cafe, a French-Vietnamese place that lives up to its reputation as one of the finest restaurants in town";
authors[3] = "<I>Departures</I> Magazine, Jan/Feb 1999";

quotes[4] = "A beguiling colonial blend of French, Louisiana Creole and Asian flavors... [T]he culinary equivalent of perfect pitch";
authors[4] = "<I>Travel & Leisure</I> Magazine, February 1999";

quotes[5] = "New Orleans isn't living in the past; it's new Creole establishments are at the forefront of American Dining...Don't overlook...the French-Vietnamese cuisine at Lemon Grass Cafe";
authors[5] = "<I>Food & Wine</I> Magazine, September 1998";

quotes[6] = "The first thing you'll notice different here is that where the traditional Vietnamese menu would list dishes by the hundred, the Lemon Grass has only a handful of offerings- about the same number as a nouvelle bistro... luscious...";
authors[6] = "Tom Fitzmorris, <I>City Business</I>, August 1996";

quotes[7] = "With all the comfort of a French cafe and all the exoticism of Vietnamese restaurant... Start your meal with one of the finest spring rolls we've encountered anywhere... You'll be amazed by the delicacy of the flavors...";
authors[7] = "<I>New Orleans Magazine</I>, September 1996";

index = Math.floor(Math.random() * quotes.length);
document.write("<DL>\n");
document.write("<DT>" + "\"" + quotes[index] + "\"\n");
document.write("<DD><SMALL>" + "<br>-- " + authors[index] + "\n");
document.write("</DL>\n");

//done -->

</script></font></td>
</tr>
</table>
</center></div></td>
</tr>
</table>
</center></div>
</body>
</html>


Now the owner wants: upon the site is activated, the index.html displays as before, then the text will refreshes randomly every 5 seconds until a full minute or soon as the title is clicked.

What I did was change the refresh statement from:
<meta http-equiv="Refresh" CONTENT="20;URL=http://www.lemongrassrest.com/index2.html">

to:
<meta http-equiv="Refresh" CONTENT="5;URL=http://www.lemongrassrest.com/index.html">

This would almost does the trick, but just almost 'cause: firstly, it would not move to index2.html in 1 full minute; secondly, he does not like the way it refreshes because the logo also refreshes that make it flicking (he said that is less elegant.)

My next idea is like below, but I don't the syntax and I don't know if there were a wait() function:

while (true) do {
index = Math.floor(Math.random() * quotes.length);
document.write("<DL>\n");
document.write("<DT><NORMAL>" + "\"" + quotes[index] + "\"\n");
document.write("<DD><SMALL>" + "<br>-- " + authors[index] + "\n");
document.write("</DL>\n");
wait(5 seconds);
blank the field;
}


I appreciate someone please help me. ngungo


.

ngungo
02-09-2003, 08:36 PM
Originally posted by Dave Clark
Insert this DIV (instead of the FONT tags) at the beginning of your TD:

<div id="quote" style="font-family:Arial; font-size:12pt; color:#3E683F;"></div>

Change your RED code to this:

function randomQuote() {
var str, div = document.getElementById('quote');
index = Math.floor(Math.random() * quotes.length);
str = '<DL>\n';
str+= '<DT>' + '&amp;quote;' + quotes[index] + '&amp;quote;\n';
str+= '<DD><SMALL>' + '<br>-- ' + authors[index] + '\n';
str+= '</DL>\n';
div.innerHTML = str;
}
window.setInterval("randomQuote()",0);
window.setInterval("randomQuote()",5000);

Dave

Hi Dave,
I did as your instructions. Thanks. There is a couple perculiar things. First, it does not display rightaway first time. I took a guess and added the line window.setInterval("randomQuote()",0);. Secondly, there is an extra e; after double quote ". This I guessed there was something to do with DIV statement, but I don't have any clue. Try it so you'll see what I meant.

http://www.lemongrassrest.com

Please help me again.





.

linnie
02-09-2003, 08:41 PM
Originally posted by ngungo
Secondly, there is an extra e; after double quote ". This I guessed there was something to do with DIV statement, but I don't have any clue.
This one you can fix by changing this:

str+= '<DT>' + '&amp;quote;' + quotes[index] + '&amp;quote;\n';

to this:

str+= '<DT>' + '&amp;quot;' + quotes[index] + '&amp;quot;\n';

I'd say that was just an oversight on Mr. Clark's part. But, you don't need to add this:

window.setInterval("randomQuote()",0);

just do it this way:

randomQuote();

Lin

ngungo
02-09-2003, 08:49 PM
Hi linnie,

I see and understand now. Thanks. ngungo



.

ngungo
02-11-2003, 12:29 AM
function randomQuote() {
var str, div = document.getElementById('quote');
index = Math.floor(Math.random() * quotes.length);
str = '<DL>\n';
str+= '<DT>' + '&quote;' + quotes[index] + '&quote;\n';
str+= '<DD><SMALL>' + '<br>-- ' + authors[index] + '\n';
str+= '</DL>\n';
div.innerHTML = str;
}


Please anyone (linnie or Mr. Clark) show me how to convert the above function to a one that makes it types the string out at certain speed. My intension is to make it slower and dramatic like (like in the movie) with a little mechanical typewritter or telegram machine sound when each character is typed out\.

It's a little challenge, huh?

Thanks,
ngungo



.

ngungo
02-11-2003, 01:36 AM
Hihihi ...

I found something URL=http://www.dynamicdrive.com/dynamicindex10/text5.htm]here[/URL], that could do what I want; but I have to go extra miles. Please help!!! Thanks!!!

Here's the code:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="description" content="Lemon Grass Restaurant - A beguiling colonial blend of French, Louisiana Creole and Asian flavors... The culinary equivalent of perfect pitch.&quot;">
<meta http-equiv="keywords" content="New Orleans, dining, restaurants, fine, best, Lemon Grass, Vietnamese, catering, banquets, chefs, Louisiana, Big Easy, Crescent City">
<meta http-equiv="Refresh" CONTENT="60;URL=http://www.lemongrassrest.com/index2.html">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<title>Lemon Grass Restaurant, New Orleans</title>
</head>

<body bgcolor="#FFFFFF" text="#1C5A00" link="#800000" vlink="#1C5A00" alink="#FFFFFF">

<p align="center">&nbsp;</p>
<div align="center"><center>

<table border="0" width="428" cellspacing="0" cellpadding="25">
<tr>
<td width="100%" align="center"><a href="index2.html">
<img src="http://www.lemongrassrest.com/logoflush.gif"
alt="Explore Lemon Grass, Wine and Dine Experience" border="0" width="428" height="125"></a></td>
</tr>
<tr>
<td width="100%" align="right"><div align="center"><center><table border="0" width="100%">
<tr>
<td width="100%" align="right"><div id="quote" style="font-family:Arial; font-size=9pt; color=#3E683F;"></div><script
LANGUAGE="JavaScript">

<!--

//Code by Mark Sottek. Ask before using please. mark@mardicard.com

quotes = new Array(8);

authors = new Array(8);

quotes[0] = "Lemon Grass feels like a respite from what we've come to perceive as the CBD- severe buildings- business suits- handshakes.";
authors[0] = "<I>New Orleans Magazine</I>, September 1999";

quotes[1] = "The space is light and refreshing, dreamy and <br>almost fantastic, much like the food.";
authors[1] = "Faith Dawson, <I>New Orleans Magazine</I>, September 1999";

quotes[2] = "Shrimp dumplings may not come to mind when you're pondering food choices in New Orleans. But chef Minh Bui's Lemon Grass Cafe is such a hit that he's opening a second place, Lemon Grass Restaurant, in the French Quarter.";
authors[2] = "<I>Food & Wine</I> Magazine, May 1999";

quotes[3] = "Friday Evening we try the Lemon Grass Cafe, a French-Vietnamese place that lives up to its reputation as one of the finest restaurants in town";
authors[3] = "<I>Departures</I> Magazine, Jan/Feb 1999";

quotes[4] = "A beguiling colonial blend of French, Louisiana Creole and Asian flavors... [T]he culinary equivalent of perfect pitch";
authors[4] = "<I>Travel & Leisure</I> Magazine, February 1999";

quotes[5] = "New Orleans isn't living in the past; it's new Creole establishments are at the forefront of American Dining...Don't overlook...the French-Vietnamese cuisine at Lemon Grass Cafe";
authors[5] = "<I>Food & Wine</I> Magazine, September 1998";

quotes[6] = "The first thing you'll notice different here is that where the traditional Vietnamese menu would list dishes by the hundred, the Lemon Grass has only a handful of offerings- about the same number as a nouvelle bistro... luscious...";
authors[6] = "Tom Fitzmorris, <I>City Business</I>, August 1996";

quotes[7] = "With all the comfort of a French cafe and all the exoticism of Vietnamese restaurant... Start your meal with one of the finest spring rolls we've encountered anywhere... You'll be amazed by the delicacy of the flavors...";
authors[7] = "<I>New Orleans Magazine</I>, September 1996";

function randomQuote() {
var str, div = document.getElementById('quote');
index = Math.floor(Math.random() * quotes.length);
str = '<DL>\n';
str+= '<DT>' + '&quot;' + quotes[index] + '&quot;\n';
str+= '<DD><SMALL>' + '<br>-- ' + authors[index] + '\n';
str+= '</DL>\n';
div.innerHTML = str;
}
randomQuote();
window.setInterval("randomQuote()",5000);

/*
Typing Text Script-
Last updated: 99/06/17
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

var it=0
function initialize(){
mytext=typing.innerText
var myheight=typing.offsetHeight
typing.innerText=''
document.all.typing.style.height=myheight
document.all.typing.style.visibility="visible"
typeit()
}
function typeit(){
typing.insertAdjacentText("beforeEnd",mytext.charAt(it))
if (it<mytext.length-1){
it++
setTimeout("typeit()",100)
}
else
return
}
if (document.all)
document.body.onload=initialize


//done -->

</script></font></td>
<small><span id="typing" style="visibility:hidden" align="right">Welcome to Dynamic Drive, the primer place on the net to get FREE Dynamic HTML scripts to enhance your web site! All scripts on this site take advantage of fourth generation browsers (IE 4.x and/or NS 4.x), with emphasis on practicality and backwards compatibility, to bring true power and interactivity to your site. The majority of scripts here are written by the programmers right here at Dynamic Drive, and cannot be found anywhere else on the net. Enjoy!</span></small>
</tr>
</table>
</center></div></td>
</tr>
</table>
</center></div>
</body>
</html>