SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get value of checkbox which is checked+jquery

    Hi to all,

    I have following checkboxes

    Code:
    <input type="checkbox" name="selector[]" 
    id="selector" value="id">#id<br> 
    <input type="checkbox" name="selector[]" 
    id="selector" value="class">.class<br> 
    <input type="checkbox" name="selector[]" 
    id="selector" value="element">element[@attribute]<br><br> 
    <input type="button" id="btnClick" name="btnClick" value="Click" />
    how i get the values of checkboxes which is checked and put that values in javascript array when i click the button using jquery.

    thanks in advance

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    $(function(){
      $('#btnClick').click(function(){
        var val = [];
        $(':checkbox:checked').each(function(i){
          val[i] = $(this).val();
        });
      });
    });
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks

  4. #4
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank u so much man.you have really saved my life

  5. #5
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great answer, it helped me. Thank you very much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •