I have this code for a random quiz, it works fine, but the client want's buttons for a multiple choice instead of a dropdown, this is the code:
<div id="QText"></div>
<br/>
<select id="choices">
<option value="">Elije una Respuesta</option>
</select>
function nextQuestion() {
var question = questions[qcount];
document.getElementById("QText").innerHTML = question[0];
var select = document.getElementById("choices");
select.options.length = 1;
for ( var a = 1; a < question.length; ++a ) {
var ans = question[a];
if ( ans.charAt(0) == "*" ) ans = ans.substring(1);
select.options[a] = new Option( ans, question[a] );
}
}
At some point i wrote a code for the input buttons but it created a button for every entry in the array
Is there a way to do this without changing the whole code?
Aucun commentaire:
Enregistrer un commentaire