Ciao a tutti, vorrei realizzare una cosa ma non ci riesco...
Questo è il codice:
abbinato acodice:<script type="text/javascript"> var text = new Array(); text[1] = "testo 1"; text[2] = "testo 2"; text[3] = "testo 3"; var footnotes = new Array(); footnotes[1] = "nota 1"; footnotes[2] = "nota 2"; footnotes[3] = "nota 3"; var quips = []; quips[0] = "bottone 1"; quips[1] = "bottone 2"; quips[2] = "bottone 3"; var cursor = 2 + Math.floor((text.length - 1)*Math.random()); $(setText()); /* function loadText() { var regex = new RegExp("\\Wq=(\\d+)"); var res = regex.exec($(location).attr('href')); if (res == null) { setText(null); } else { setText(res[1]); } } */ function setText(index) { if (index == null || index < 1) { index = cursor; } $('#text').html(text[index]); $('#footnote').html('' + footnotes[index] + ''); $('#index').html('#' + index); $('#quip').text( quips[Math.floor(Math.random()*quips.length)] ); if(cursor >= text.length -1){ cursor = 1; } else{ cursor++; } } </script>
Adesso, quando sono su testo 1 e clicco sul bottone, compare testo 2. Quando sono su testo 2, compare testo 3. Quando sono su testo 3, ricomincia da testo 1.codice:Bottone
Vorrei però che quando clicco su bottone comparisse un testo "random": cioè, non sempre nell'ordine 1, 2 e poi 3.
Qualcuno sa come aiutarmi?
Sono giorni che ci impazzisco!!
Grazie mille
Nicola