Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScript ~ I need to disable 2 checkboxes when the 3rd checkbox is selected
    primarykey
    data
    text
    <p>I need checkBox 3 to disable checkBox 1 &amp; 2 when it is selected. The code works when I have the <code>onClick</code> in the 3rd checkbox tag, but my lead programmer wants the <code>onClick</code> in the JavaScript code above. I'm not that good with JS so I don't know exactly why it's not working. This is what I have so far:</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt; &lt;meta name="Content-Script-Type" content="text/javascript"&gt; &lt;meta name="Content-Style-Type" content="text/css"&gt; &lt;title&gt;Example&lt;/title&gt; &lt;SCRIPT TYPE="text/javascript"&gt; &lt;!-- var field = document.getElementById("check_1157"); if (field) { function update1157Box(contactMethod) { var contactMethod = document.getElementById("check_1157"); if(contactMethod.check_1157.checked) { //enable the not to receive information contactMethod.check_1156.disabled =true; contactMethod.check_1156.checked = false; contactMethod.check_1158.disabled =true; contactMethod.check_1158.checked = false; return; } } field.onClick = update1157Box(this.form) //the not to receive information contactMethod.check_1156.checked = false; contactMethod.check_1156.disabled = false; contactMethod.check_1158.checked = false; contactMethod.check_1158.disabled = false; } //--&gt; &lt;/SCRIPT&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;div class="many-from-many"&gt; &lt;label style="display: block;"&gt;&lt;input id="check_1156" name="answers[166][]" value="1156" type="checkbox"&gt;Check Box 1&lt;/label&gt; &lt;label style="display: block;"&gt;&lt;input id="check_1158" name="answers[166][]" value="1158" type="checkbox"&gt; Check Box 2&lt;/label&gt; &lt;label style="display: block;"&gt;&lt;input id="check_1157" name="answers[166][]" value="1157" type="checkbox"&gt;Check Box 3&lt;/label&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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