Select all checkboxes with JQuery

Select all checkboxes with JQuery

More then once you need to select all checked checkboxes in your web application. With JQuery this is a piece of cake. The following code returns all the checked checkbox values in an array AND in a string;

[javascript]
<script type="text/javascript">
function getchecked(){
// Get checked values
var selected = new Array();
$(‘input[type=checkbox]:checked’).each(function() {
selected.push($(this).val());
});
// convert to a string
var mystring = selected.join(",");
}
</script>
[/javascript]

In case you only need to get the checkboxes within a “div” you would something like this:

[javascript]
<script type="text/javascript">
function getchecked(){
// Get checked values
var selected = new Array();
$(‘#mydiv input:checked’).each(function() {
selected.push($(this).val());
});
// convert to a string
var mystring = selected.join(",");
}
</script>
[/javascript]

and in case you don’t need the values, but only the names you would use:

[javascript]
<script type="text/javascript">
function getchecked(){
// Get checked values
var selected = new Array();
$(‘input[type=checkbox]:checked’).each(function() {
selected.push($(this).attr(‘name’));
});
// convert to a string
var mystring = selected.join(",");
}
</script>
[/javascript]

Now, if you put this is a globally accessible function you will never have to revisit the code and it simply works in your project 🙂 Have fun.

Helpmonks All-in-one Customer Service Platform
Coldfusion: How to pass struct and array in a URL

A user just asked: I need to pass my array to a webserver. But somehow, the array passed with cfhttp throws an error. Please help You can not pass a structure or an array in a URL as they are complex values and Coldfusion does not have a way to…

Helpmonks All-in-one Customer Service Platform
OpenBD and MongoDB: Can't get easier then this

I'm currently working on a project that uses MongoDB (yes, that's the awesome NoSQL database everyone talks about). Now, my favorites language of choice (CFML) and especially my favorite open source CFML engine OpenBD, has support for MongoDB built in which makes it a snap to use for any ColdFusion…

Helpmonks All-in-one Customer Service Platform
Updating Confluence and Jira is a nightmare and keeps you hunting for solutions

First off, I really like Jira and Confluence and we have been using them successfully for all our open source applications. We also use HipChat for our IM communication and use SourceTree for managing code on Github. Just realised that Atlassian has become a company to depend on... This post…

Helpmonks All-in-one Customer Service Platform
7 Cognitive Psychology Hacks for a Winning Email Marketing Script Writing

Email marketing is an important segment of your digital marketing strategy. Big and small businesses use it to communicate with customers and send the right messages at the right moments. Email marketing helps to acquire new customers, increase sales, and advertise new products, services, or events. But, none of this…

Helpmonks All-in-one Customer Service Platform
How to create a virtual machine server image from a physical CentOS server

I run a couple of servers over at a server farm. All of those machines run VMWare ESX, so today I wanted to move my last physical server to a VMWare image. If you want to convert a physical Windows machine then your task is quite easy. Start up the…

Helpmonks All-in-one Customer Service Platform
Exchange, Kerio, Zimbra and Google or the Quest for the perfect Collaboration tool

One of my main goals in my everyday work flow is to keep all my informations at one central location and have access to them from everywhere. Meaning I want all my emails, contacts and calendar entries in sync, whether I use my mobile phone, my own laptop or I…

Trusted by over 2,000 organizations with millions of emails

Helpmonks helps us answer customer emails at lighting speed
We couldn't do our job without Helpmonks!
Helpmonks, the best thing since sliced bread
Excellent option for collaborating email amongst your team
A good platform that is here to grow and help you grow
Helpmonks is a great tool that our company utilizes and depends on
Great shared inbox for the team
Fantastic email support service for any business
Easy to navigate and catalog data for specific users
Solid Helpdesk software w/ responsive customer support
A really good solution to manage customer support mailbox
Good support, useful features

One more thing...

Helpmonks gives you the ability tocollaborate as a groupin your shared mailbox, features aTeam To-Do App, powerfulCustomer Relationship Management (CRM)capabilities, integratedLive-Chatand Email Marketing Tools for email newsletter and automated email campaigns, collision detection, email tracking, reminders, mentions, custom fields, custom applications, customer satisfaction ratings, Single-Sign-On (SSO) & SAML authentication, Trello, Zapier, Slack, an API, and much more.

Check outthe complete feature listor sign up for afree 30-day shared inbox trial now