douzhi1919 2015-12-26 04:43
浏览 21
已采纳

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

I have small php quiz script something like this:

<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

  • 写回答

1条回答 默认 最新

  • download1002 2015-12-26 04:51
    关注

    Assign a class answer to each of the 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line