Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否在插入值时未选中复选框?_Javascript_Php_Jquery_Html_Mysqli - Fatal编程技术网

Javascript 是否在插入值时未选中复选框?

Javascript 是否在插入值时未选中复选框?,javascript,php,jquery,html,mysqli,Javascript,Php,Jquery,Html,Mysqli,代码: $(文档).ready(函数(){ $(“#保存_考试”)。单击(函数(){ var student_id=$('#student_id').val(); var student_firstname=$('#student_firstname').val(); var student_lastname=$('#student_lastname').val(); var exam_name=$('#exam_name').val(); var date=$('#date').val();

代码:


$(文档).ready(函数(){
$(“#保存_考试”)。单击(函数(){
var student_id=$('#student_id').val();
var student_firstname=$('#student_firstname').val();
var student_lastname=$('#student_lastname').val();
var exam_name=$('#exam_name').val();
var date=$('#date').val();
window.location=window.location.href+'&student='+student\u id+'&student\u firstname='+student\u firstname+'&student\u lastname='+student\u lastname+'&test\u name='+test\u name+'&date='+date
});
});
查询:

<script>
  $(document).ready(function(){
    $('#save_exam').click(function(){
      var student_id=$('#student_id').val();
      var student_firstname=$('#student_firstname').val();
      var student_lastname=$('#student_lastname').val();
      var exam_name=$('#exam_name').val();
      var date=$('#date').val();

      window.location=window.location.href+'&student='+student_id+'&student_firstname='+student_firstname+'&student_lastname='+student_lastname+'&exam_name='+exam_name+'&date='+date
    });
  });
</script>

您没有使用checked='checked'属性。
请在复选框中添加checked='checked'属性,如

<form method="post">
    <?php
      if($studentid == '')
      {
        echo '';
      }
      else
      {
    ?>
    <input type="checkbox" name="save_exam" id="save_exam">&nbsp;&nbsp;<b style="color: #337ab7;">Mark And Save This Exam</b>
    <?php
      }
    ?>
    <input type="hidden" name="student_id" id="student_id" value="<?php echo $student_id; ?>">
    <input type="hidden" name="student_firstname" id="student_firstname" value="<?php echo $student_firstname; ?>">
    <input type="hidden" name="student_lastname" id="student_lastname" value="<?php echo $student_lastname; ?>">
    <input type="hidden" name="exam_name" id="exam_name" value="<?php echo $exam_name; ?>">
    <input type="hidden" name="date" id="date">
  </form>
标记并保存此考试

您没有使用checked='checked'属性。 请在复选框中添加checked='checked'属性,如

<form method="post">
    <?php
      if($studentid == '')
      {
        echo '';
      }
      else
      {
    ?>
    <input type="checkbox" name="save_exam" id="save_exam">&nbsp;&nbsp;<b style="color: #337ab7;">Mark And Save This Exam</b>
    <?php
      }
    ?>
    <input type="hidden" name="student_id" id="student_id" value="<?php echo $student_id; ?>">
    <input type="hidden" name="student_firstname" id="student_firstname" value="<?php echo $student_firstname; ?>">
    <input type="hidden" name="student_lastname" id="student_lastname" value="<?php echo $student_lastname; ?>">
    <input type="hidden" name="exam_name" id="exam_name" value="<?php echo $exam_name; ?>">
    <input type="hidden" name="date" id="date">
  </form>
标记并保存此考试

将您的输入更改为:

<input type="checkbox" name="save_exam" checked='checked' id="save_exam">&nbsp;&nbsp;<b style="color: #337ab7;">Mark And Save This Exam</b>

将您的输入更改为:

<input type="checkbox" name="save_exam" checked='checked' id="save_exam">&nbsp;&nbsp;<b style="color: #337ab7;">Mark And Save This Exam</b>

您可以添加
checked
属性。您可以添加
checked
属性。如果我给出checked='checked',则它总是显示复选框。我想当我点击复选框时,页面将在重新加载页面后重新加载复选框未选中。您可以根据需要将其置于特定条件下。就像条件一样,如果我给checked='checked',则它始终显示复选框选中。我想当我点击复选框时,页面将在重新加载页面后重新加载复选框未选中。您可以将其置于特定条件下,无论您想要什么。如conditon@Jeff-上述代码将在重新加载后选中复选框。谢谢programmingandroid@Jeff-选择作为正确答案,如果您觉得有用,请向上投票:)@Jeff-以上代码将重新加载后选中复选框。谢谢programmingandroid@Jeff-选择作为正确答案,如果您觉得有用,请向上投票:)
<?php session_start();
    $sql = "select * from students where student_id = '$student_id'";
    $result = mysqli_query($link,$sql);
    while ($row = mysqli_fetch_array($result)) 
    {
      $studentid = $row['student_id'];
      $student_firstname = $row['firstname'];
      $student_lastname = $row['lastname']; 
    }

    if(isset($_GET['student_firstname']))
      {
        extract($_GET);
        $query = "select * from student_exams where exam_name = '$exam_name' and student_id ='$student_id'";
        $result = mysqli_query($link,$query);
        $row = mysqli_fetch_array($result);
        if($row > 0 )
        {
          $_SESSION['saved'] = "false";// Change made HERE, this variable stores your result
          $msg .="<h5 style='text-align:center;color:red;'>Your Exam Detail Already Exist. Please Select Other Exam.</h5>";
        }
        else
        {
            $sql = "insert into student_exams(student_id,student_firstname,student_lastname,exam_name,date)values('$student_id','$student_firstname','$student_lastname','$exam_name','$date')";
            $result=mysqli_query($link,$sql);
            if($result == true)
            {
            $msg .="<h4 style='text-align:center;color:green;'>Your Data Has Been Submitted Successfully.</h4>";
            $_SESSION['saved'] = "true";// Change made HERE, this var stores your result

            }
            else
            {
              $_SESSION['saved'] = "false";// Again, this variable stores your result
              $msg .="<h4 style='text-align:center;color:red;'>Error</h4>";
            }
        }
      }
    ?>