How to retrieve checkboxes values in jQuery

前端 未结 15 2217
时光说笑
时光说笑 2020-11-22 10:11

How to use jQuery to get the checked checkboxes values, and put it into a textarea immediately?

Just like this code:


  
  &l         


        
15条回答
  •  滥情空心
    2020-11-22 10:45

    You can also return all selected checkboxes value in comma separated string. This will also make it easier for you when you send it as a parameter to SQL

    Here is a sample that return all selected checkboxes values that have the name "chkboxName" in comma separate string

    And here is the javascript

    function showSelectedValues()
    {
      alert($("input[name=chkboxName]:checked").map(
         function () {return this.value;}).get().join(","));
    }
    

    Here is the HTML sample

    
      
     
     
      

提交回复
热议问题