普通网友 2013-10-30 07:51
浏览 52
已采纳

使用js和php设置并显示表单的倒数计时器

I have an exam form. i want to set and show a countdown timer (for example 60 minutes) as the student open the page. if they post the form after that specific time it wont be acceptable and they lose the exam.

how can i do that? only using js or need using php as well?

i'm a new so need some clear codes!

Thanks

  • 写回答

1条回答 默认 最新

  • douzhong4222 2013-10-30 08:01
    关注

    Consider using a database for this or some kind of server-side check. When the student opens the test for the first time, the time should be stored in a database and the shown time should be calculated. Otherwise refreshing the page would reset the timer. At the end if the time of submitTime-startTime < 60 seconds then he/she made it in time.

    This means that you need PHP for example. It should call a method which stores the current time if a field in database if it isn't allready stored and then do the same after submit. If the time of submit is present in the database, you shouldn't allow him/her to do the test again.

    JavaScript should only be used for the display of time, not for validity checking alone without any server-side checking.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!