Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript Change Text in X Seconds - No Initial Display
    primarykey
    data
    text
    <p>I currently have a JavaScript file that will change the testimonial shown every five seconds. Everything works perfectly, except for the first five seconds, nothing appears. If I put a value where the JavaScript function is being called, it does show up initially, then is replaced by whatever the first testimonial is. </p> <p>Here is the HTML code where the JavaScript is being called.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;SCRIPT language="JavaScript" SRC="textCycle.js"&gt;&lt;/SCRIPT&gt; &lt;/head&gt; &lt;body&gt; &lt;table border = 0&gt;&lt;tr&gt;&lt;td style="width:300px;"&gt; &lt;!-- Change the height in order to determine width of quotes --&gt; &lt;div id="change"&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is the Javascript:</p> <pre><code>var quotes=new Array(5); var i = 0; var authors=new Array(5); //Load Quotes into array quotes[0]="\"Website is awesome!\""; quotes[1]="\"Love it!\""; quotes[2]="\"Awesome site!\""; quotes[3]="\"This site was very informative and helped with my problem.\""; quotes[4]="\"Best site for helping with this issue.\""; //Load authors that correspond with the quote array authors[0]="Anonymous"; authors[1]="Anonymous"; authors[2]="Anonymous"; authors[3]="Anonymous"; authors[4]="Anonymous"; //Call the changeText() function every 5000 miliseconds setInterval(changeText, 5000); //Function that determine what quote and author to put in html. function changeText(){ document.getElementById("change").innerHTML=(quotes[i] + '&lt;p style="text-align: right"&gt;&lt;i&gt;' + authors[i] + '&lt;/i&gt;&lt;/p&gt;'); if(i == 4) i = 0; else i++; } </code></pre> <p>Is this just a matter of changing the javascript file so that quotes[0] is outside of the loop?</p> <p><em>Note: The values in the arrays were changed to keep it anonymous. These aren't real testimonials.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload