First of all here the html calling the external javascript:
< script type="text/javascript" src="js/textlines.js"></script>
And here is my javascript from the file above:
// set up lines of html in an array
textcontent[0] = '<p class="swapcelltextbig">This is texcontent 0.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
textcontent[1] = '<p class="swapcelltextbig">This is texcontent 1.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
textcontent[2] = '<p class="swapcelltextbig">This is texcontent 2.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
textcontent[3] = '<p class="swapcelltextbig">This is texcontent 3.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
// measure array size and randomly pick one
var textshow=textcontent.length
var currenttext=Math.floor(Math.random()*textshow)
//write the picked html into the page
document.write('currenttext')
Please help me get this working. I'm new to JavaScript, and thought this would be a simple way to start using it.
< script type="text/javascript" src="js/textlines.js"></script>
And here is my javascript from the file above:
// set up lines of html in an array
textcontent[0] = '<p class="swapcelltextbig">This is texcontent 0.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
textcontent[1] = '<p class="swapcelltextbig">This is texcontent 1.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
textcontent[2] = '<p class="swapcelltextbig">This is texcontent 2.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
textcontent[3] = '<p class="swapcelltextbig">This is texcontent 3.</p><p class="swapcelltext">another paragraph?</p><p class="swapcelltext">final paragraph?</p>'
// measure array size and randomly pick one
var textshow=textcontent.length
var currenttext=Math.floor(Math.random()*textshow)
//write the picked html into the page
document.write('currenttext')
Please help me get this working. I'm new to JavaScript, and thought this would be a simple way to start using it.