java脚本onClick无法正常工作

时间:2015-10-30 09:19:12

标签: javascript php html

我真的需要一些帮助,我整晚都在努力工作,只是不能让我的功能发挥作用我已经尝试了所有的东西,现在我已经到了必须在一小时内递交的地方。



<input type="button" value="Sub" onclick = "alert('The text will be show!!'); return false;"/> 
&#13;
&#13;
&#13; 我把它放在那里工作,但当我尝试调用我的函数时注意到。

非常感谢任何帮助。

&#13;
&#13;
<!DOCTYPE html>
<html>
<style>
</style>

<head>
  <script>
    var score = 0;

    function DoTotals() {
      window.alert("sometext");
      alert('sometext');
    }

    function getScore() {
      window.alert("sometext");
      alert("sometext");
      alert('sometext');

      var inputs = document.querySelectorAll("input");

      for (int i = 0; i < inputs; i++) {

        if (inputs[i].type == "radio" && inputs[i].checked && inputs[i].value == "correct") {
          score += 1;
        } else {

          var userInputString = inputs[i].value;
          var correctAnswer = inputs[i].getAttribute('data-correct');

          if (userInputString != null && correctAnswer != null) {

            if (userInputString.toUpperCase() == correctAnswer.toUpperCase()) {
              score += 1;
            }

          }
        }
      }

      document.getElementById("score").innerHTML = "You Scored " + score;
      score = 0;
    }
  </script>
</head>

<body>
  <input type="button" value="Sub" onclick="alert('The text will be show!!'); return false;" />

  <table border="2">
    <?php //Open the file with the questions $questionFile=f open( "testFile.txt", 'r'); $radioGroupId=0; //while the reader has npt reached the end of the file while(!feof($questionFile)){ //get line for text file $line=f gets($questionFile); echo '<tr>';
    //If this line is a multiple choice question if(strpos($line, '#MC') !==f alse){ //break the line into substrings $breakDownLine=e xplode( ';',$line); //insert each element of the array into the table for ($i=0;$i<count($breakDownLine);$i++){ if($i==0){
    //Remove the MC indicator $question=s tr_replace( "#MC", "",$breakDownLine[$i]); echo '<td style="border:2px solid red;">'; echo $question. '</td>'; } else{ echo '<td style="border:2px solid black;">'; if(strpos($breakDownLine[$i], '*')!=false){ $answerRemove=s
    tr_replace( "*", "",$breakDownLine[$i]); echo $answerRemove. '<input type="radio" name="var'.$radioGroupId. '" value="correct">'; } else{ echo $breakDownLine[$i]. '<input type="radio" name="var'.$radioGroupId. '" value="incorrect">'; } } } } //If
    this line is a True / False question else if(strpos($line, '#TF') !==f alse){ //break the line into substrings $breakDownLine=e xplode( ';',$line); for ($i=0;$i<count($breakDownLine);$i++){ if($i==0){ //Remove the MC indicator $question=s tr_replace(
    "#TF", "",$breakDownLine[$i]); echo '<td style="border:2px solid red;">'; echo $question. '</td>'; } else{ echo '<td style="border:2px solid black;">'; if(strpos($breakDownLine[$i], '*')!=false){ $answerRemove=s tr_replace( "*", "",$breakDownLine[$i]);
    echo $answerRemove. '<input type="radio" name="var'.$radioGroupId. '" value="correct">'; } else{ echo $breakDownLine[$i]. '<input type="radio" name="var'.$radioGroupId. '" value="incorrect">'; } } } } else if(strpos($line, '#FIB') !==f alse){ echo
    '<td style="border:2px solid red;">'; while (true){ $pos=s trpos($line, "["); $pos2=s trpos($line, "]"); $pos3=$ pos2-$pos; $subAnswer=s ubstr($line,$pos+1,$pos3-1); if ($pos2===f alse) { echo $line; break; // no more blanks i.e. no more [. } else { $out=s ubstr($line,0,$pos); echo
    $out; $line=s ubstr($line,$pos2+1,strlen($line)); echo '<input type="text" data-correct="'.$subAnswer. '">'; } } } echo '</tr>'; $radioGroupId++; } ?>


  </table>

  <button onClick="DoTotals()">Click me</button>
  <p id="score"></p>

</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)

而不是

for (int i = ...

写:

for (var i = ...