I wish to have readers have the the optiom to chose to read alternative chapters in a story.
right now I'm useing:
WithCode:function swap(what) { var theDivs = document.getElementsByTagName('div'); for(var i = 0; i < theDivs.length; i++) { if(theDivs[i].id.search('swap') == 0) { theDivs[i].style.display = 'none'; } } document.getElementById('swap'+what).style.display = 'block'; } window.onload = function() { var theDivs2 = document.getElementsByTagName('div'); for(var j = 0; j < theDivs2.length; j++) { if(theDivs2[j].id.search('swap') != -1) { theDivs2[j].style.display = 'none'; } } }
Unfortunately, I would I like the Originals versions to not be hidden on load, and only hidden when an alternative chapter, for /that chapter/ is chosen. While at the moment only one alternative version of any chapter is being used, it would be nice if the code could support a possibility of more than oneCode:<h5 id="partN1">Part N1</h5> <p>blah</p> <h5 id="partN2">Part N2 - Read: <span class="button" onclick="swap(0)">Original</span> | <span class="button" onclick="swap(1)">Alternative</span> parts</h5> <div id="swap0"> <p>blah</p> </div> <div id="swap1" class="alt"> <p>blah</p> </div> <h5 id="partN3">Part N3</h5> <p>blah</p> <h5 id="partN4">Part N4 - Read: <span class="button" onclick="swap(2)">Original</span> | <span class="button" onclick="swap(3)">Alternative</span> parts</h5> <div id="swap2"> <p>blah</p> </div> <div id="swap3" class="alt"> <p>blah</p> </div>




Reply With Quote
