我有一个像这样的小型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>
我的问题是当我点击answer1或2或3或4时,它会转到下一个问题而不点击下一个按钮
答案 0 :(得分:0)
为每个答案分配一个班级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
});
或者您可以在页面上隐藏隐藏变量,以便跟踪下一个问题并在next() function
填充下一个问题