HowdeeDoodee
Technical User
How can I iterate through the variables below and display only one sentence on the screen at a time, using a button onclick event to trigger the display of the sentence. As the code is written now, all four sentences display on the screen at one time and there is no button.
Thank you in advance for any replies.
I am a total novice.
<script type="text/javascript">
//any number of elements can be assigned to an array
var sentence = new Array()
sentence[0] = "Saab is driven by smart people."
sentence[1] = "Volvo is an automobile."
sentence[2] = "BMW is for the rich and famous."
sentence[3] = "Ford is for the economy minded."
for (i=0;i<sentence.length;i++)
{
document.write(sentence + "<br />")
}
Thank you in advance for any replies.
I am a total novice.
<script type="text/javascript">
//any number of elements can be assigned to an array
var sentence = new Array()
sentence[0] = "Saab is driven by smart people."
sentence[1] = "Volvo is an automobile."
sentence[2] = "BMW is for the rich and famous."
sentence[3] = "Ford is for the economy minded."
for (i=0;i<sentence.length;i++)
{
document.write(sentence + "<br />")
}