Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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/5/ruby/24.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
Php 如何在警报中显示正确的数字_Php_Jquery_Html - Fatal编程技术网

Php 如何在警报中显示正确的数字

Php 如何在警报中显示正确的数字,php,jquery,html,Php,Jquery,Html,我对警报中显示的问题编号有疑问。它不是显示问题编号,而是将问题id显示为问题编号。因此,在警报验证中,它表示,例如: You have errors on question number: 115 当它应该说时,您在问题编号上有错误:例如,3 现在,此代码显示问题id:value=”“ 此代码显示问题编号:echo$searchQuestionNo[array\u search($questionId,$searchQuestionId)] 但当我尝试这样做时: <input type=

我对警报中显示的问题编号有疑问。它不是显示问题编号,而是将问题id显示为问题编号。因此,在警报验证中,它表示,例如:

You have errors on question number: 115
当它应该说
时,您在问题编号上有错误:例如,3

现在,此代码显示问题id:
value=”“

此代码显示问题编号:
echo$searchQuestionNo[array\u search($questionId,$searchQuestionId)]

但当我尝试这样做时:

<input type='hidden' id='num_groups' name='num_groups' value='<?php echo$searchQuestionNo[array_search($questionId, $searchQuestionId)]`?>'>


我假设,正如您所说,此代码允许重新筛选问题编号:

echo$searchQuestionNo[array_search($questionId, $searchQuestionId)]

将问题编号添加为输入元素中的属性
q\u编号

<input class="individualMarks q<?php echo$questionId?>_mark" q_number="<?php echo $searchQuestionNo[array_search($questionId, $searchQuestionId)]; ?>" q_group="1" name="answerMarks[]" type="text" data-type="qmark" data-qnum="<?php echo$questionId?>" onkeypress="return isNumberKey(event)" maxlength="3" value="0" />

请考虑以下几点建议:尤其是在删除问题并再次提问时,你能为这件事做点什么吗?嗨,它没有起作用。它正在做同样的事情。当我尝试更改代码以显示问题编号时,如我的尝试和您在回答中尝试的一样,当我有一个文本输入,该文本输入对于
。individualMarks
,而不是在所有惩罚标记中显示未输入值的错误消息时,它通过验证直接进入确认。尝试使用控制台(F12)调试代码,并在click handler函数中放置断点。这是第一次尝试使用F12调试,因此请耐心等待,它会在click handler函数的else语句中突出显示
return false
。在
scope variables
部分,它声明
e:jQuery.Event group:6 ng:“5”this:form#PenaltyMarks
我不知道这是否相关检查此链接:调试器将允许找出问题。使用断点和分步功能确定谢谢链接,我想我之前的评论对你没有帮助吧?
  < script type = "text/javascript" >


    myClickHandler = function (e) {
      var ng = $('#num_groups').val();
      for (var group = 1; group 
           <= ng; group++) {
        if (!validation(group)) return false;
      }

    });


    function validation(group) {
      var msg = [];

      var nb = 0; // Number of blank values
      $("input[data-qnum='" + group + "']").each(function () {
        if ($(this).val() == '') {
          nb++;
          return false;
        }
      });
      if (nb != 0) {
        msg.push("\u2022 You have not entered in a value in all the Penalty Marks textbox \n");
      }

      if (msg.length >
          0) {
        alert("You have errors on Question Number: " + group + "\n\n" + msg.join("\n"));
        return false;
      } else {
        return true;
      }
    }




    < /script>
echo$searchQuestionNo[array_search($questionId, $searchQuestionId)]
<input class="individualMarks q<?php echo$questionId?>_mark" q_number="<?php echo $searchQuestionNo[array_search($questionId, $searchQuestionId)]; ?>" q_group="1" name="answerMarks[]" type="text" data-type="qmark" data-qnum="<?php echo$questionId?>" onkeypress="return isNumberKey(event)" maxlength="3" value="0" />
function validation(group) {
  var msg = [];

  var qNumber = null;

  var nb = 0; // Number of blank values
  $("input[data-qnum='" + group + "']").each(function () {

    //Assign the question number
    qNumber = $(this).attr('q_number');

    if ($(this).val() == '') {
      nb++;
      return false;
    }
  });
  if (nb != 0) {
    msg.push("\u2022 You have not entered in a value in all the Penalty Marks textbox \n");
  }

  //Use qNumber instead of the group variable
  if (msg.length > 0) {
    alert("You have errors on Question Number: " + qNumber + "\n\n" + msg.join("\n"));
    return false;
  } else {
    return true;
  }
}