Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript anything slider numbers to text Re: anything slider numbers to text

#78603
oneworld95
Member

Create an array outside of the formatText function and set each element of the array to the text you’d like to use. Ensure the array index matches the panel index, then reference the array element in the formatText function.

Code:
var nameArray = new Array(“Name 1″,”Name 2″,”Name 3″,”Name 4″,”Name 5″,”Name 6”)
function formatText(index, panel){
var myHtml = “

My text for Panel #” + index + ” is ” + nameArray[index] + “


return myHtml;
}

Make sure each array element’s text is for the panel you wish; in other words, "Name 1" goes with the first panel and so forth. You can replace the text in the array elements with whatever text or HTML you want to use.