Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is the following javascript not being executed?
    primarykey
    data
    text
    <p>I'm new to web programming and I have the following form that I wish to validate.</p> <pre><code>&lt;form name="feature_request_view" action="FeatureRequestView.php" method="post" onsubmit="return validateAllFields()"&gt; &lt;p id="errorMsg" style="color:red"&gt;&amp;nbsp;&lt;/p&gt; &lt;div class="noboder"&gt; &lt;label for="approval"&gt;* Approve the feature request?:&lt;/label&gt; &lt;input type="radio" name="approval[]" id="approval" value="1" /&gt; Yes &lt;input type="radio" name="approval[]" id="approval" value="0" /&gt; No * &lt;/div&gt; &lt;div class="button-style"&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>The javascript code is as follows:</p> <pre><code>&lt;script type="text/javascript" src="../validation.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function validateAllFields() { var approval = document.getElementsByName("approval"); var errors = document.getElementById("errorMsg"); errors.innerHTML = ""; if(checked(approval, errors, "Please choose an option to approve/disapprove the feature request.")) { window.alert("got in the if block"); errors.innerHTML = "Your decision has been submitted."; return true; } return false; } &lt;/script&gt; </code></pre> <p>And the checked function that I used is:</p> <pre><code>function checked(element, error, msg) { var boxchecked = false; for (i = 0; i &lt; element.length; i++) { if (element[i].checked) { boxchecked = true; } } if (boxchecked) { return true; } else { error.innerHTML = msg; return false; } } </code></pre> <p>My problem is that the code never executes the javascript and therefore by passing it even though the radio buttons have not been filled in and it begins to execute some php that i used to populate a table. Please help! Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload