Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2010
    Posts
    235
    Thanks
    39
    Thanked 6 Times in 6 Posts

    jquery retrieve all checkboxes in a form value

    I have a filter form which has multiple checkbox groupings on it, such as gender which has 3 possible values, status which has 5 possible values, city which has 3 possible areas. I need to get the name of the checkbox and the value for each group that is checked. The code below is what I've been asked to get into. I did the advfil line.

    The item is the name of each checkbox, say gender, city, status. I just need the value from each of those.

    Code:
    function applyAdvSearch(){
      trace("applyAdvSearch entered");
      advfil="";
      //var sg = jQuery("#reportmainsearch").filterGrid("#reportgrid",{gridModel: true, gridNames:false})[0];  
      var checkedArr = getArrCheckedItems();
      $("#reportmain input:text").each(function(){if($(this).css("visibility")=="hidden"){$(this).attr("value","");}});
      if(typeof checkedArr == "object"){
        for(var item in checkedArr){
          if(typeof checkedArr[item] == "object"){
            try{
            tempstr = checkedArr[item].join(",");
            trace("#reportmain input:[name="+item+"]:text");
            // stack url to send over filters
            advfil=advfil + "&" + item + "=" + $('#advsearchbox.' + item + ').val();
            //trace($("#reportmain input:[name="+item+"]:text").attr("name"));
             $("#reportmain input:[name="+item+"]:text").attr("value",tempstr);
            }catch(e){trace(e)}
         }
        }
      }

  • #2
    Regular Coder
    Join Date
    Mar 2010
    Posts
    235
    Thanks
    39
    Thanked 6 Times in 6 Posts
    Got it:

    Code:
    advfil=advfil + "&" + item + "=" + $("#advsearchbox input:checkbox[name="+item+"]:checked").val();
    What a great day to be alive!


  •  

    Posting Permissions

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