It worked with me just putting it straight onto the page, but when I tried adding it to a table, it didn't work:
http://smcodes.smfforfree3.com/pages/smcodes/test.php
Also, how do I make it so that each array will be in <tr><td> tags?
Code:
<script type="text/javascript">
<!--
var texts = [];
texts[0] = ["text1","Blah1"];
texts[1] = ["text2","Blah2"];
texts[2] = ["text3","Blah3"];
texts[3] = ["text4","Blah4"];
texts[4] = ["text5","Blah5"];
texts[5] = ["text6","Blah6"];
texts.factor = 2; //Set to the number of texts to display
texts.num = -texts.factor;
texts.p = function(){
texts.num -= texts.factor;
texts.num = texts.num > -1? texts.num : texts.length + texts.num;
texts.d();
};
texts.n = function(){
texts.num += texts.factor;
texts.num = texts.num < texts.length? texts.num : texts.num - texts.length;
texts.d();
};
texts.d = function(){
if(texts.length%texts.factor){
alert('The number of texts must be evenly divisible by the factor');
return;
}
'prev'.vis(texts.num > 0? 0 : 1);
'nxt'.vis(texts.num < texts.length - texts.factor? 0 : 1);
for (var i = texts.factor - 1; i > -1; --i)
texts.el[i * 2].nodeValue = texts[texts.num + i].join(': ');
}
String.prototype.reveal = function(){
for (var a = this.split(' '), i = a.length - 1; i > -1; --i)
document.getElementById(a[i]).style.display = 'block';
};
String.prototype.vis = function(h){
for (var a = this.split(' '), i = a.length - 1; i > -1; --i)
document.getElementById(a[i]).style.visibility = h? 'hidden' : 'visible';
};
texts.init = function(){
for (var el = document.getElementById('output'), i = texts.factor; i > 1; --i){
el.appendChild(document.createElement('br'));
el.appendChild(document.createTextNode('\xa0'));
}
texts.el = el.childNodes;
'output controls'.reveal();
texts.n();
}
if(typeof window.addEventListener!='undefined')
window.addEventListener('load', texts.init, false);
else if(typeof window.attachEvent!='undefined')
window.attachEvent('onload', texts.init);
// -->
</script>
<script type="text/javascript"><!--
document.write("<div class='tborder'><div class='catbg' style='padding: 6px; vertical-align: middle; text-align: center;' mce_style='padding: 6px; vertical-align: middle; text-align: center;'>The Affiliate Page</div><div><table border='0' width='100%' cellspacing='1' cellpadding='4' class='bordercolor'><tr><td class='titlebg'><a onclick='AddYours();'>Add Your Affiliate</a></td></tr><tr><td class='windowbg2' width='100%'><span id='AffiliateSec'>We are Currently Working on the affiliate page, please be patient during the change.</span></td></tr></table></div></div><br>");
function AddYours(){
document.getElementById("AffiliateSec").innerHTML = "In Order to add your affiliate to this page, you must be a <b>Member</b> of Simple Machine Codes, and you must have at least <b>10 legit posts</b> on Simple Machine Codes. If you don't, and you request to get your affiliate on this page, your post will get deleted, and your affiliate will not get added.<br /><br />If you do have <b>10 posts</b>, all you have to do is post in this topic: <a href='http://smcodes.smfforfree3.com/index.php/topic,688.0.html' mce_href='http://smcodes.smfforfree3.com/index.php/topic,688.0.html' style='cursor: pointer;' mce_style='cursor: pointer;'>Add Your Affiliate</a><br /><br />Oh, and one last thing, please follow the guidelines in the first post. If you don't, your post will be deleted.";
};
document.write("<div class='tborder'><div class='catbg' style='padding: 6px; vertical-align: middle; text-align: center;' mce_style='padding: 6px; vertical-align: middle; text-align: center;'>Our Affiliates</div><div><table border='0' width='100%' cellspacing='1' cellpadding='4' class='bordercolor'><tr><td class='windowbg' id='output'><br mce_bogus="1" /></td></tr></table><table><table border='0' width='100%' cellspacing='1' cellpadding='4' class='bordercolor'><tr class='windowbg2'><td id='controls'><center><input id='prev' type='button' value='Previous' onclick='texts.p();' /> <input id='nxt' type='button' value='Next' onclick='texts.n();' /></center></td></tr></table></div></div><br>");
// --></script>
Bookmarks