Creación de un cuestionario en dreamweaver
- Halim_akiki
- Born


- Registrado: Jul 10, 2011
- Mensajes: 1
- Status: Offline
Hola. necesito hacer una prueba en dreamweaver utilizando botones de opción para obtener las respuestas. im teniendo un problema en la liberación de botones de opción después de comprobar una radio y pasar a una siguiente pregunta mediante una "próxima >>" botón de la misma radio registra la primera pregunta es seleccionado en la segunda pregunta. ¿alguien me puede ayudar con esto? Gracias. Esto es todo el ejercicio:
Código: [ Select ]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Quiz Easy</title>
<script type="text/javascript">
var questions=["Lebanon's capital:","France's capital:","England's capital:"];
var answers=[["beyrouth","sayda","tripoli"],
["souchaux","paris","lyon"],
["manchester","cambridge","london"]];
var trueAnswers=[0,1,2];
var chosenAnswers=[-1, -1, -1];
var cur=0;
var grade=0;
function start(){
cur = 0;
showQuestion();
}
function showQuestion(){
quest.innerText = (cur+1) + ") "+questions[cur];
rep1.innerText = answers[cur][0];
rep2.innerText = answers[cur][1];
rep3.innerText = answers[cur][2];
}
function goNext(){
if (cur < questions.length-1){
cur++;
showQuestion();
}
}
function goPrevious(){
if (cur > 0 ){
cur--;
showQuestion();
}
}
function goFirst(){
cur = 0;
showQuestion();
}
function goLast(){
cur = questions.length-1;
showQuestion ();
}
/*function getAnswers ()
{
for (i=0, i<answers.length, i++)
{
for(j=0, j<answers[i].length, j++)
{
if(answers[i][j].checked)
chosenAnswers[i] = answers[i][j];
else
chosenAnswers[i] = -1;
}
}
}*/
/*function getAnswer() {
chosenAnswers = "";
len = answers.length;
for (i = 0; i <len; i++) {
if (answers[i].checked) {
chosenAnswers = answers[i];
return chosenAnswers;
}
else{
return -1;
}
}
}*/
function checkAnswer(){
grade = 0;
for (i=0; i<trueAnswers.length; i++){
if (trueAnswers[i] == chosenAnswers[i]){
grade = grade + 1;
}
}
}
function score(){
alert("You had a score of " + grade + " points!")
}
function clearRB(buttonGroup)
{
for (i=0; i < buttonGroup.length; i++) {
if (buttonGroup[i].checked == true) { // if a button in group is checked,
buttonGroup[i].checked = false; // uncheck it
}
}
}
</script>
</head>
<body onload="start()">
<form name="clearIt">
<h1 id="quest"> </h1>
<p> <input type="radio" name="radioA" id="radio1"/> <span id="rep1"> </span> </p>
<p> <input type="radio" name="radioA" id="radio2"/> <span id="rep2"> </span> </p>
<p> <input type="radio" name="radioA" id="radio3"/> <span id="rep3"> </span> </p>
<p> <input type="button" name="clear" value="clear" onclick="clearRB(document.clearIt.radioA)" /> </p>
</form>
<p><input type="button" value="First |<<" onclick="goFirst()"/>
<input type="button" value="Previous <" onclick="goPrevious()"/>
<input type="button" value="Next >" onclick="goNext()"/>
<input type="button" value="Last >>|" onclick="goLast()"/>
<input type="button" value="Submit Answers" onclick="checkAnswer()"/>
<input type="button" value="Show Result" onclick="score()"/></p>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Quiz Easy</title>
<script type="text/javascript">
var questions=["Lebanon's capital:","France's capital:","England's capital:"];
var answers=[["beyrouth","sayda","tripoli"],
["souchaux","paris","lyon"],
["manchester","cambridge","london"]];
var trueAnswers=[0,1,2];
var chosenAnswers=[-1, -1, -1];
var cur=0;
var grade=0;
function start(){
cur = 0;
showQuestion();
}
function showQuestion(){
quest.innerText = (cur+1) + ") "+questions[cur];
rep1.innerText = answers[cur][0];
rep2.innerText = answers[cur][1];
rep3.innerText = answers[cur][2];
}
function goNext(){
if (cur < questions.length-1){
cur++;
showQuestion();
}
}
function goPrevious(){
if (cur > 0 ){
cur--;
showQuestion();
}
}
function goFirst(){
cur = 0;
showQuestion();
}
function goLast(){
cur = questions.length-1;
showQuestion ();
}
/*function getAnswers ()
{
for (i=0, i<answers.length, i++)
{
for(j=0, j<answers[i].length, j++)
{
if(answers[i][j].checked)
chosenAnswers[i] = answers[i][j];
else
chosenAnswers[i] = -1;
}
}
}*/
/*function getAnswer() {
chosenAnswers = "";
len = answers.length;
for (i = 0; i <len; i++) {
if (answers[i].checked) {
chosenAnswers = answers[i];
return chosenAnswers;
}
else{
return -1;
}
}
}*/
function checkAnswer(){
grade = 0;
for (i=0; i<trueAnswers.length; i++){
if (trueAnswers[i] == chosenAnswers[i]){
grade = grade + 1;
}
}
}
function score(){
alert("You had a score of " + grade + " points!")
}
function clearRB(buttonGroup)
{
for (i=0; i < buttonGroup.length; i++) {
if (buttonGroup[i].checked == true) { // if a button in group is checked,
buttonGroup[i].checked = false; // uncheck it
}
}
}
</script>
</head>
<body onload="start()">
<form name="clearIt">
<h1 id="quest"> </h1>
<p> <input type="radio" name="radioA" id="radio1"/> <span id="rep1"> </span> </p>
<p> <input type="radio" name="radioA" id="radio2"/> <span id="rep2"> </span> </p>
<p> <input type="radio" name="radioA" id="radio3"/> <span id="rep3"> </span> </p>
<p> <input type="button" name="clear" value="clear" onclick="clearRB(document.clearIt.radioA)" /> </p>
</form>
<p><input type="button" value="First |<<" onclick="goFirst()"/>
<input type="button" value="Previous <" onclick="goPrevious()"/>
<input type="button" value="Next >" onclick="goNext()"/>
<input type="button" value="Last >>|" onclick="goLast()"/>
<input type="button" value="Submit Answers" onclick="checkAnswer()"/>
<input type="button" value="Show Result" onclick="score()"/></p>
</body>
</html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Quiz Easy</title>
- <script type="text/javascript">
- var questions=["Lebanon's capital:","France's capital:","England's capital:"];
- var answers=[["beyrouth","sayda","tripoli"],
- ["souchaux","paris","lyon"],
- ["manchester","cambridge","london"]];
- var trueAnswers=[0,1,2];
- var chosenAnswers=[-1, -1, -1];
- var cur=0;
- var grade=0;
- function start(){
- cur = 0;
- showQuestion();
- }
- function showQuestion(){
- quest.innerText = (cur+1) + ") "+questions[cur];
- rep1.innerText = answers[cur][0];
- rep2.innerText = answers[cur][1];
- rep3.innerText = answers[cur][2];
- }
- function goNext(){
- if (cur < questions.length-1){
- cur++;
- showQuestion();
- }
- }
- function goPrevious(){
- if (cur > 0 ){
- cur--;
- showQuestion();
- }
- }
- function goFirst(){
- cur = 0;
- showQuestion();
- }
- function goLast(){
- cur = questions.length-1;
- showQuestion ();
- }
- /*function getAnswers ()
- {
- for (i=0, i<answers.length, i++)
- {
- for(j=0, j<answers[i].length, j++)
- {
- if(answers[i][j].checked)
- chosenAnswers[i] = answers[i][j];
- else
- chosenAnswers[i] = -1;
- }
- }
- }*/
- /*function getAnswer() {
- chosenAnswers = "";
- len = answers.length;
- for (i = 0; i <len; i++) {
- if (answers[i].checked) {
- chosenAnswers = answers[i];
- return chosenAnswers;
- }
- else{
- return -1;
- }
- }
- }*/
- function checkAnswer(){
- grade = 0;
- for (i=0; i<trueAnswers.length; i++){
- if (trueAnswers[i] == chosenAnswers[i]){
- grade = grade + 1;
- }
- }
- }
- function score(){
- alert("You had a score of " + grade + " points!")
- }
- function clearRB(buttonGroup)
- {
- for (i=0; i < buttonGroup.length; i++) {
- if (buttonGroup[i].checked == true) { // if a button in group is checked,
- buttonGroup[i].checked = false; // uncheck it
- }
- }
- }
- </script>
- </head>
- <body onload="start()">
- <form name="clearIt">
- <h1 id="quest"> </h1>
- <p> <input type="radio" name="radioA" id="radio1"/> <span id="rep1"> </span> </p>
- <p> <input type="radio" name="radioA" id="radio2"/> <span id="rep2"> </span> </p>
- <p> <input type="radio" name="radioA" id="radio3"/> <span id="rep3"> </span> </p>
- <p> <input type="button" name="clear" value="clear" onclick="clearRB(document.clearIt.radioA)" /> </p>
- </form>
- <p><input type="button" value="First |<<" onclick="goFirst()"/>
- <input type="button" value="Previous <" onclick="goPrevious()"/>
- <input type="button" value="Next >" onclick="goNext()"/>
- <input type="button" value="Last >>|" onclick="goLast()"/>
- <input type="button" value="Submit Answers" onclick="checkAnswer()"/>
- <input type="button" value="Show Result" onclick="score()"/></p>
- </body>
- </html>
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Julio 10th, 2011, 6:49 am
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 1 mensaje
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 97 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
