Logic behind certain check boxes.

Hi,

Can anyone help me implement this logic:

I Have these boxes:

instructions.png
here is there code:
          <div class="check-container" style="margin-left: 67px;margin-top: 16px;">
            <div class="img-container"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='1' name="inst_doorman"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="1" class='checked'></div>
              <span class="checkboxdesc">Leave with doorman</span>
          </div><br>

         <div class="check-container" style="margin-left: -205px;margin-top: 25px;">
            <div class="checkboxdesc"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='2' name="inst_call"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="2" class='checked'></div>
              <span class="checkboxdesc">Call upon arrival</span>
          </div><br>

          <div class="check-container" style="margin-left: -200px;margin-top: 35px;">
            <div class="checkboxdesc"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='3' name="inst_vestible"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="3" class='checked'></div>
              <span class="checkboxdesc">Leave in vestibule</span>
          </div><br>

           <div class="check-container" style="margin-left:-200px;margin-top:43px;">
            <div class="checkboxdesc"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='4' name="inst_other"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="4" class='checked'></div>
              <span class="checkboxdesc">Other</span>
          </div><br>

            <div class="check-container" style="margin-left: 0px;margin-top: -70px">
            <div class="checkboxdesc"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='5' name="inst_back"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="5" class='checked'></div>
              <span class="checkboxdesc"> Leave at back door</span>
          </div><br>

           <div class="check-container" style="margin-left: 0px;margin-top: -58px;">
            <div class="checkboxdesc"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='6' name="inst_front"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="6" class='checked'></div>
              <span class="checkboxdesc"> Leave at front door</span>
          </div><br>

            <div class="check-container" style="margin-right: 64px;float: right;margin-left: -15px;margin-top: -47px;width: 239px;">
            <div class="checkboxdesc"> <img  src="../assets/images/check-box.png" class="checkboxs" cartcheck='7' name="inst_apt"><img  src="../assets/images/check-box2.png" style="display: none" cartchecked="7" class='checked'></div>
              <span class="checkboxdesc"> Leave in front of apt door</span>
          </div><br>


         <div class="text-area-container" style="margin-left: 65px!important;">

         <textarea style="resize: none;font-family:open_sanslight" placeholder="Special Instructions"class="txt-area instructions" name="inst_spec" id="inst_spec"></textarea>
         </div>

Open in new window


how can i implement this logic:
If user checks:      
- Call upon arrival         -> ALL other boxes are available till user checks additional box
- Leave at back door      -> Disable all others EXCEPT “OTHER” & TEXT BOX &call upon arrival
- Leave at front door      -> Disable all others EXCEPT “OTHER” & TEXT BOX &call upon arrival
- Leave in front of Apt Door      -> Disable all others EXCEPT “OTHER” & TEXT BOX &call upon arrival
- Leave in vestibule      -> Disable all others EXCEPT “OTHER” & TEXT BOX &call upon arrival
- Leave w/ Doorman      ->Disable all others EXCEPT “OTHER” & TEXT BOX &call upon arrival
- Other      -> enabled at all times
-text -> enabled at all times
LVL 1
Jazzy 1012Asked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
Is this what you want
CSS
.checkbox-panel input[type="checkbox"],
.checkbox-panel input[type="radio"] {
  display: none!important;
}
.checkbox-panel label {
  display: block;
  background-image: url(images/checkbox.png);
  background-repeat: no-repeat;
  max-height: 20px;
  line-height: 20px;
  padding-left: 30px;
}
.checkbox-panel input:checked + label {
  background-position: 0 -20px;
}

Open in new window

HTML
<div class="row checkbox-panel">
  <div class="col-md-6">
	<input type="radio" value="doorman" id="doorman" name="leave"><label for="doorman">Leave with the doorman</label>
	<input type="radio" value="vestibule" id="vestibule" name="leave"><label for="vestibule">Leave in vestibule</label>
	<input type="radio" value="backdoor" id="backdoor" name="leave"><label for="backdoor">Leave at back door</label>
	<input type="checkbox" value="other" id="other" name="other"><label for="other">Other</label>
  </div>
  <div class="col-md-6">
	<input type="checkbox" value="callonarrival" id="callonarrival" name="callonarrival"><label for="callonarrival">Call upon arrival</label>
	<input type="radio" value="aptdoor" id="aptdoor" name="leave"><label for="aptdoor">Leave in front of apt door</label>
	<input type="radio" value="frontdoor" id="frontdoor" name="leave"><label for="frontdoor">Leave at front door</label>
  </div>
  <div class="col-md-12">
	<textarea name="comment" class="form-control"></textarea>
	<br>
	<button class="btn btn-primary pull-right">Submit</button>
  </div>
</div>

Open in new window


Working sample here
0
 
ste5anConnect With a Mentor Senior DeveloperCommented:
Your leave options are radio buttons. E.g.

Radio Button Group
    RadioButton Leave at back door
    RadioButton Leave at front door
    RadioButton Leave in front of Apt Door
    RadioButton Leave in vestibule
    RadioButton Leave w/ Doorman

CheckBox    Call upon arrival
CheckBox    Other
TextBox     text

as

<!DOCTYPE html>
<html>
    <body>
        <form>
            <fieldset>
                <label><input type="radio" name="Leave" value="BD">Leave at back door</label>
                <label><input type="radio" name="Leave" value="FD">Leave at front door</label>
                <label><input type="radio" name="Leave" value="AD">Leave in front of Apt Door</label>
                <label><input type="radio" name="Leave" value="VT">Leave in vestibule</label>
                <label><input type="radio" name="Leave" value="WD">Leave w/ Doorman</label>
                <label><input type="checkbox" name="CUA" value="salami">Call upon arrival</label>
                <label>Other<input type="text" name="Other" value="schinken"></label>
            </fieldset>
        </form>
</body>
</html>

Open in new window

0
 
Jazzy 1012Author Commented:
Also, is there a way to make it that if the user enters text inside the text area, the other is automatically checked if it wasnt.
0
 
Julian HansenCommented:
Yup, based on the accepted solution add this jQuery
<script>
$(function() {
  $('textarea').keyup(function() {
    $('input[name="other"]').prop({checked: !!this.value.length});
  });
});
</script>

Open in new window

Updated sample here
1
 
Jazzy 1012Author Commented:
Great thanks alot!
0
All Courses

From novice to tech pro — start learning today.