Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkbox values fail if not selected?

Tags:

html

css

I'm building this checkbox that it woyld only work if all 3 checkboxes are checked on the web. Otherwise it will fail.

I tried to set without value - but it doesn't work at all.

I tried to give them the same value as the name or field - doesn't work.

Works only if the value is set as true - but for some reason it expects it all to be true?

<fieldset class="question-fieldset twocolinputs">
  <h2>Question #81:</h2>
  <div class="answer-single">
    <input id="2-a" name="MX3A" type="checkbox" class="checkbox-button-input" value="true">
    <label class="answer-label" for="2-a">
      Email
      </label>
  </div>
  <div class="answer-single">
    <input id="2-b" name="MX3B" type="checkbox" class="checkbox-button-input" value="true">
    <label class="answer-label" for="2-b">
      SMS
      </label>
  </div>
  <div class="answer-single">
    <input id="2-c" name="MX3C" type="checkbox" class="checkbox-button-input" value="true">
    <label class="answer-label" for="2-c">
      Llamada
      </label>
  </div>
</fieldset>
like image 909
Rain Avatar asked Dec 18 '25 11:12

Rain


1 Answers

In an <input> of type checkbox, you set the checked property to true, not the value:

<input id="2-b" name="MX3B" type="checkbox" class="checkbox-button-input" checked="true">
                                                                             ▲
like image 75
Koby Douek Avatar answered Dec 21 '25 05:12

Koby Douek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!