[Solved] HTML checkboxes and input options [closed]


If you want to create inputs on the fly you can use the following:

$(".myCheckbox").on("change", function() {
    var value = $(this).val();
    if (this.checked) {
        $(this).parent().append('<input id="checkboxInput'+value+'" type="text" maxlength="254" name="checkboxInput'+value+'">');
    } else {
        $('#checkboxInput'+value).remove();
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">

  <div class="checkboxWrapper">
    <input class="myCheckbox" id="checkbox1" type="checkbox" name="someName[]" value="1" />
    <label for="checkbox1">Value 1</label>
  </div>

  <div class="checkboxWrapper">
    <input class="myCheckbox" id="checkbox2" type="checkbox" name="someName[]" value="2" />
    <label for="checkbox2">Value 2</label>
  </div>

  <div class="checkboxWrapper">
    <input class="myCheckbox" id="checkbox3" type="checkbox" name="someName[]" value="3" />
    <label for="checkbox3">Value 3</label>
  </div>

</div>

solved HTML checkboxes and input options [closed]