繁体   English   中英

如何制作将答案发送到其他页面的表单

[英]How to make a form that sends answers to a different page

我正在为我的学校制作一个出勤网页,因为他们现在使用的网页效率不高。 基本上,教师获得登录名,并且他们使用复选框指定学生是否缺席。 (我正在使用Bootstrap Toggle)我希望有一个页面,当老师按下提交按钮时,缺席学生当前页面上的数据将转到“管理”页面,因此该页面表示缺课的学生。

基本上,我需要将复选框的状态发送到其他页面。 最简单的方法是什么?

我会做的方式是通过发出ajax调用。 我会做一个javascript函数,从复选框中收集信息,即那些缺席的学生的id,然后将这些id发送到管理页面,该页面将具有php函数进行处理。 我不知道您使用的是哪种页面,但是您在问最简单的方法,所以这就是我的方法。

 function getCheckBoxInfo()
 {
     ///code here to iterate through checkboxes and
     // find those that are checked/unchecked +
   // their respective ids or names (e.g. value fields in html), 
     //  google - looping through checkboxes

  // then you place them in a number of variables
 /// i would create maybe 10-15 variables, i dont think
 /// more than that would be absent
   //and then you send those variable to managePage.php
  //using this ajax call

 if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
   }
  else
   {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
  {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("result").innerHTML=xmlhttp.responseText;

     }
   }
   xmlhttp.open("GET","managePage.php?var1="+var1+"&var2="+var2,true);
  xmlhttp.send();
   }

然后在managePage.php中提取这些变量:var1 = $ _GET [“ var1”]。

您可能还想研究jquery ajax调用,它们更加紧凑。

您还可以谷歌-通过ajax调用从javascript发送数据到php页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM