Im needing a script (Javascript I think) that can display alternating text. there is a javascript for displaying random images, but I need to display random text. anyone? or will this have to be php? any suggestions or ideas? thanks
I would do this in php, but you can modify that script to use text instead <html> <head> <script type="text/javascript"> // ============================================== // Copyright 2003 by jsCode.com // Source: jsCode.com // Author: etLux // Free for all; but please leave in the header. // Changed By James Barcellano // ============================================== // Set up the image files to be used. var theText = new Array() // do not change this // To add more image files, continue with the // pattern below, adding to the array. Rememeber // to increment the theImages[x] index! theText[0] = 'Phrase 0' theText[1] = 'Phrase 1' theText[2] = 'Phrase 2' theText[3] = 'Phrase 3' theText[4] = 'Phrase 4' // ====================================== // do not change anything below this line // ====================================== var j = 0 var p = theText.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theText[i] } var whichText = Math.round(Math.random()*(p-1)); function showText(){ document.write('<span>' + theText[whichText] + '</span>'); } </script> </head> <body> Random text : <script type="text/javascript">showText();</script> </body> </html> HTML: Tested and works.