Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing document.getElementsByClass with Checkboxes
    primarykey
    data
    text
    <p>I have cut this code and I'm not that familiar using Class. </p> <pre><code>&lt;form&gt; &lt;input type="checkbox" name="Symptom1" class=sound value="case1"&gt; Poor Sound Quality&lt;br&gt; &lt;input type="checkbox" name="Symptom2" class=sound value="case2"&gt; Only One Speaker is Working&lt;br&gt; &lt;input type="checkbox" name="Symptom3" class=sound value="case3"&gt; No Sound&lt;br&gt; &lt;input type="checkbox" name="Symptom4" class=sound value="case4"&gt; Low Volume&lt;br&gt; &lt;input type="checkbox" name="Symptom5" class=sound value="case5"&gt; Crackling Sound&lt;br&gt; &lt;input type="checkbox" name="Symptom6" class=battery value="case6"&gt; Drain Easily&lt;br&gt; &lt;input type="checkbox" name="Symptom7" class=battery value="case7"&gt; Flickering Screen&lt;br&gt; &lt;input type="checkbox" name="Symptom8" class=battery value="case8"&gt; Battery Physically Wobbled&lt;br&gt; &lt;input type="checkbox" name="Symptom9" class=battery value="case9"&gt; Turn Off from Now and Then&lt;br&gt; &lt;input type="checkbox" name="Symptom10" class=battery value="case10"&gt; Does not Charge&lt;br&gt; &lt;/form&gt; &lt;button onclick="Submit()"&gt;Submit&lt;/button&gt; </code></pre> <p>Here is my submit function that I am working on.</p> <pre><code>function Submit() { if (document.getElementsByClassName('sound').checked) { alert("You Picked Sound");} } else { alert("none"); } } </code></pre> <p>What I wanted to do is if the user checked at least one of the checkboxes under the same class (i.e. sound) then pressed submit. It would alert the user that he/she picked that class. But apparently it would not and rather it always alert me with none. Help?</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.
 

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