Chrys
08-18-2011, 04:08 AM
I am trying to display testimonials on my website in an iframe. This way I can utilize the scrolling feature if needed and keep the page from changing sizes due to the length of the testimonial. I can also change the testimonials order and content easily.
I am trying to make a "next" and "previous" button that will sit on the main page (not in the iframe) and cycle through the testimonials. However I am having trouble with this as I am trying to use an array.
This is my current code for the Next button. The idea is to check to see if the testimonial is on the last document. If so display the first testimonial in the array. "Else" change to the next testimonial in the array.
var myTests=new Array();
myTests[0]="test001.html";
myTests[1]="test002.html";
myTests[2]="test003.html";
var numTests = myTests.length;
var curTests = 0
function nextTests()
{
if (curTest <= numTests)
document.getElementById("testFrame").src=myTests(1);
else
document.getElementById("testFrame").src=myTests[0];
}
Then I am using a simple button to call the function "onclick"
<button type="button" onclick="nextTests()">next</button>
PS I am a beginner at this so I apologize if I am making silly mistakes. However, I would really appreciate any direction you can give me! Thanks so much!
I am trying to make a "next" and "previous" button that will sit on the main page (not in the iframe) and cycle through the testimonials. However I am having trouble with this as I am trying to use an array.
This is my current code for the Next button. The idea is to check to see if the testimonial is on the last document. If so display the first testimonial in the array. "Else" change to the next testimonial in the array.
var myTests=new Array();
myTests[0]="test001.html";
myTests[1]="test002.html";
myTests[2]="test003.html";
var numTests = myTests.length;
var curTests = 0
function nextTests()
{
if (curTest <= numTests)
document.getElementById("testFrame").src=myTests(1);
else
document.getElementById("testFrame").src=myTests[0];
}
Then I am using a simple button to call the function "onclick"
<button type="button" onclick="nextTests()">next</button>
PS I am a beginner at this so I apologize if I am making silly mistakes. However, I would really appreciate any direction you can give me! Thanks so much!