
|
Put some radio buttons and a TEXTAREA on a FORM and name them, like this: <FORM NAME = "iljtextareaform1"> <INPUT TYPE = "radio" NAME = "iljradio" onClick = "if(this.checked) {iljtextval(0)}2">Q.. 1 <INPUT TYPE = "radio" NAME = "iljradio" onClick = "if(this.checked) {iljtextval(1)}2">Q.. 2 <INPUT TYPE = "radio" NAME = "iljradio" onClick = "if(this.checked) {iljtextval(2)}2">Q.. 3 <TEXTAREA NAME = "iljtextarean3" ROWS = "8" COLS = "30" WRAP = "physical"> </TEXTAREA> </FORM> Clicking on a radio button calls the function iljtextval(). The first time this happens the function textwriter(), that takes care of the actual writing, is also called (from iljtextval()). Put the JavaScript below within SCRIPT tags in the HEAD part of the documentl, see MINIMANUAL 1 basics. calledx = 0 function iljtextval(textnummer) //4 { text = new Array() text[0] = "Solitude - après le feu d´artifice" + " une étoile filante Shiki" text[1] = "To Generalize is to be an Idiot."+ " To Particularize"+ " is the Alone Distinction of Man."+ " William Blake (1757-1827)" text[2] = "Born Originals, how comes it"+ " to pass that we die Copies?"+ " Young (in Conjectures on"+ " Original Composition)" texten=text[textnummer] //5 i=0 j=0 if(calledx==0) { calledx=1 textwriter() } //6 } function textwriter() //7 { document.iljtextareaform1.iljtextarean3.value ="" document.iljtextareaform1.iljtextarean3.value = texten.substring(0,i) + "|" iljtimer = setTimeout("textwriter()",150) //8 i++ if(i==texten.length+5) //9 { document.iljtextareaform1.iljtextarean3.value= " " i=0 j=j+1 } if(j==2) //10 { clearTimeout(iljtimer) //11 j=0 calledx=0 } } Do not forget to remove the footnotes! 1 name the FORM 2 when you click the button and it is checked the function iljtextval() is called - the number within parentheses keeps track of which text to write to the TEXTAREA 3 name the TEXTAREA 4 if, for instance, you´ve clicked the third button then textnummer = 2 5 texten = text[textnummer] - thus, e.g. text[2] 6 this makes sure that the function textwriter() is called only ONCE from the function iljtextval() 7 the function textwriter() does the actual writing to the TEXTAREA 8 the function textwriter() here calls itself, the number (milliseconds) decides how often it does so and thus how quickly the text will be written 9 this is where the writing starts all over again - if you want the text to be visible a little longer once it has been written you can change this number 10 j keeps track of how many times the text is written 11 stops the timer Page by ilj@flowsim.se Last modified: October 17, 1997 This page is part of a frames system at: http://www.flowsim.se/ |