[英]How can I go for next question without click next button?
I have small php quiz script something like this:我有这样的小 php 测验脚本:
<input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/>
<label class="radio" for='radio1_<?php echo $result['id'];?>'><?php echo $result['answer1'];?> </label>
<br/>
<input type="radio" value="2" id='radio2_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>' onclick="next()"'/>
<label class="radio" for='radio2_<?php echo $result['id'];?>' ><?php echo $result['answer2'];?></label>
<br/>
<input type="radio" value="3" id='radio3_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>' />
<label class="radio" for='radio3_<?php echo $result['id'];?>'/><?php echo $result['answer3'];?></label>
<br/>
<input type="radio" value="4" id='radio4_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/>
<label class="radio" for='radio4_<?php echo $result['id'];?>'><?php echo $result['answer4'];?></label>
<br/>
<button id='next1' class='next' type='button'>Next</button>
My question is when I am click on answer1 or 2 or 3 or 4 it will go for next question without click next button我的问题是当我点击 answer1 或 2 或 3 或 4 时它会进入下一个问题而无需点击下一步按钮
Assign a class answer
to each of the answer为每个答案分配一个班级answer
$('.answer').click(function(){
next();
//next() should contain logic to go to next question
//this.attr('id') this.attr('name') should provide you name/id
//of answer clicked and based on it you could decide whats the
//current and next question
});
Or you could have a hidden variable hidden on page which will keep track of next question and in next() function
populate next question或者你可以在页面上隐藏一个隐藏变量,它将跟踪下一个问题并在next() function
中填充下一个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.