Showing posts with label Get Checkbox values comma separated using jquery. Show all posts
Showing posts with label Get Checkbox values comma separated using jquery. Show all posts

Sunday, August 19, 2012

Get Checkbox values comma separated using jquery

<div id="c_b">
<div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="swimmingpool" id="swimmingpool" value="1"></div>
                                    <div class="peroperty_text">Swimming Pool</div>
                                    </div>
                                      <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="fitnesscenter" id="fitnesscenter" value="2"></div>
                                    <div class="peroperty_text">fitness center</div>
                                    </div>
                                      <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="restaurant" id="restaurant" value="3"></div>
                                    <div class="peroperty_text">restaurant</div>
                                    </div>
                                      <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="childrenactivities" id="childrenactivities" value="4"></div>
                                    <div class="peroperty_text">children’s activities</div>
                                    </div>
                                    
                                     <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="complimentarybreakfast " id="complimentarybreakfast " value="5"></div>
                                    <div class="peroperty_text">complimentary breakfast </div>
                                    </div>
                                    
                                     <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="meetingfacilities" id="meetingfacilities" value="6"></div>
                                    <div class="peroperty_text">meeting facilities</div>
                                    </div>
                                    
                                    
                                    <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="petsallowed " id="petsallowed " value="7"></div>
                                    <div class="peroperty_text">pets allowed </div>
                                    </div>
                                    
                                     <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="wheelchair" id="wheelchair" value="8"></div>
                                    <div class="peroperty_text">wheelchair accessible</div>
                                    </div>
                                    
                                    <div class="checktextrow">
                                    <div class="peroperty_checks"><input type="checkbox" name="kitchen" id="kitchen" value="9"></div>
                                    <div class="peroperty_text">kitchen/kitchenette</div>
                                    </div>
</div>

 <textarea id="t"></textarea>



Here is jquery code for access all checkbox using jquery and set the checkboxes values in textarea.



 function updateTextArea() {
         
         var allVals = [];
         $('#c_b :checked').each(function() {
           allVals.push($(this).val());
         });
         $('#t').val(allVals)
      }
     $(function() {
       $('#c_b input').click(updateTextArea);
         updateTextArea();
     });



complete  working example can be check here 



.net core

 Sure, here are 50 .NET Core architect interview questions along with answers: 1. **What is .NET Core, and how does it differ from the tradi...