I have a list of checkboxes which will repeat themselves from backend... but on frontend I have a list of 4 checkboxes and i want to show a textbox on every checkbox click.
That is if one checkbox is clicked then 1 text box should be shown and if 4 checkboxes are clicked then 4 textboxes should be shown.
I am able to do this if I trigger different event on different text box but that won't work when data is coming anonymously.
This is my html markup:
<form>
<div class="form-group">
<label><strong>Events Hosted</strong><sup class = "venue-imp">*</sup></label>
<br />
<div class="row">
<div class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
<div class="col-lg-3 col-md-3 col-xs-6 col-sm-6">
<label class="checklist" for="wr">
<input type="checkbox" value="" id="wr">Wedding &Reception
<span class="checkmark"></span></label>
<div id="yesWR" style="display: none">
<input type="number" id="yesWR" placeholder="Hosted!!" />
</div>
</div>
<div class="col-lg-3 col-md-3 col-xs-6 col-sm-6">
<label class="checklist" for="weddings">
<input type="checkbox" value="" id="weddings">Weddings
<span class="checkmark"></span></label>
<div id="yesWed" style="display: none">
<input type="number" id="yesWed" placeholder="Hosted!!" />
</div>
</div>
<div class="col-lg-3 col-md-3 col-xs-6 col-sm-6">
<label class="checklist" for="bday">
<input type="checkbox" value="" id="bday">Bday Party
<span class="checkmark"></span></label>
<div id="yesBday" style="display: none">
<input type="number" id="yesBday" placeholder="Hosted!!" />
</div>
</div>
<div class="col-lg-3 col-md-3 col-xs-6 col-sm-6">
<label class="checklist" for="anniversary">
<input type="checkbox" value="" id="anniversary">Anniversary
<span class="checkmark"></span></label>
<div id="yesAnn" style="display: none">
<input type="number" id="yesAnn" placeholder="Hosted!!" />
</div>
</div>
</div>
</div>
</div>
</form>
and this is the jQuery code
/*anniversary*/
$(function () {
$("#anniversary").click(function () {
if ($(this).is(":checked")) {
$("#yesAnn").show();
} else {
$("#yesAnn").hide();
}
});
});
/*bday*/
$(function () {
$("#bday").click(function () {
if ($(this).is(":checked")) {
$("#yesBday").show();
} else {
$("#yesBday").hide();
}
});
});
/*Weddings*/
$(function () {
$("#weddings").click(function () {
if ($(this).is(":checked")) {
$("#yesWed").show();
} else {
$("#yesWed").hide();
}
});
});
/*Weddings and Reception*/
$(function () {
$("#wr").click(function () {
if ($(this).is(":checked")) {
$("#yesWR").show();
} else {
$("#yesWR").hide();
}
});
});
now for every checkbox i am performing different event which is not the solution help!!