1

I really need some help i have been working on this all night and just cant get my function to work i have tried every thing and now i am at the point where it has to to handed in in a hour.

The

<input type="button" value="Sub" onclick = "alert('The text will be show!!'); return false;"/> 
I put there works but when i try call my functions noting.

Any help would very much appreciated.

<!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>

4
  • @Yeldar , did u edit this The I put there works but when i try call my funtions noting. ? Commented Oct 30, 2015 at 9:23
  • @aishwatsingh Hello. I just have formatted a code and removed "Alex" signature. Commented Oct 30, 2015 at 9:25
  • Thanks I am new to this Commented Oct 30, 2015 at 9:26
  • If you paste this code into a good development tool like WebStorm, it immediately highlights the error. Commented Oct 30, 2015 at 9:39

1 Answer 1

3

Instead of

for (int i = ...

write:

for (var i = ...
Sign up to request clarification or add additional context in comments.

2 Comments

You sir are a saint. Thanks so much really appreciate it. I was having a melt down there.
@AlexanderKirwan but i have

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.