简体   繁体   English

如何在不单击下一步按钮的情况下进入下一个问题?

[英]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.

相关问题 如何单击按钮,并使用javascript使有问题的项目转到下一个列表? - How to click on a button, and have the item in question go to the next list using javascript? 如何通过使用 jQuery 单击按钮来获得下一个问题 - how can I get the next question by clicking on button using jQuery 当我点击按钮时,问题没有进入下一个 - Question is not advancing to the next one when I click the button 单击下一步按钮时问题索引未更新 - Question index not updating when I click next button 当我单击 gliderjs 中的下一个/上一个按钮时,页面 go 到顶部 - Page go to top when i click on next/prev button in gliderjs 当我点击 next.js 中的按钮时,如何将 go 转到外部链接 - How do I go to an external link when I click on a button in next js 如何编码,以便用户在输入上一个问题的答案后只能转到下一个问题? HTMLl/JS - How can I code such that the user can only go to the next question after inputting an answer for the previous question? HTMLl/JS 单击转盘项目内的按钮如何转到下一个转盘项目 - How to go to next carousel item on click of a button inside carousel item 如何使用 api 转到下一页? - How can I go to the next page with the api? 当我点击下一个按钮时,上一个问题必须用反向 animation 删除,下一个问题必须显示输入效果 animation - When i click on next button, the previous question must be remove with reverse animation & next question must be show with typing effect animation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM