Checkbox - What is checked? Jquery?

You can use jQuery's .each() API: $('inputtype="submit"'). Click(function() { var output = ''; $('inputtype="checkbox":checked'). Each(function(index) { output += $(this).val() + ", "; }); alert(output + "is checked!"); }); Test page: pastebin.com/LVuLUthB As for removing the commas, there will be no commas when processing in PHP.

Checkboxes are sent as an array. What you want to do is: And then in the PHP: echo implode(', ', $_POST'checkbox') .' are checked!

This code: $('inputtype="submit"'). Click(function() { var output = ''; $('inputtype="checkbox":checked'). Each(function(index) { output += $(this).text() + ", "; } alert(output + "is checked!"); }); Gives me unexpected token ) error.

– Oliver 'Oli' Jensen Aug 26 at 17:19 sorry, idiotic syntax error - forgot to close brackets for each. Updated code. – Jonathan Lingle Aug 26 at 17:21 Works now.

Although, it just says ", is checked". It does not gives the values from the checkboxes. – Oliver 'Oli' Jensen Aug 26 at 17:24 ahhhh I clearly need more coffee.

Okay, I've updated & tested the code and it should work now. – Jonathan Lingle Aug 26 at 17:46.

Two controls cannot have the same ID. Subject to fixing #1, it is easy to use .val() and/or to treat the returned jQuery collection as an ordered sequence. Since #1 is fixed this will require a selector based on type or name, etc.The code in the post does not interact with PHP.

Consider revising the question/code. Note that (note the name) might be useful for handling on the server as a collection. Happy coding.

Take a look at jQuery .each(). The following will iterate through all checked checkboxes. As @zod states in his comment, IDs are unique, use a class instead.

$("input"). Click(function() { $(":checked"). Each(function() { $("#log").

Html($(this).val() + " is checked! "); }); }).

Try this sitepoint.com/forums/javascript-15/get-v... $(function(){ $('#btnClick'). Click(function(){ var val = ; $(':checkbox:checked'). Each(function(i){ vali = $(this).val(); }); }); }); and refer this too api.jquery.com/checked-selector.

.val() will always return the value of the first matched element: api.jquery.com/val/ Try this: $("input"). Click(function() { $(":checked"). Each(function() { $("#log").

Html( this.val() + " is checked! " ); }) }).

Like @zod said, you will need different ids on your checkboxes. In addition, you will need a loop to process all the checkboxes. Try this: var total = ""; $(":checked").

Each(function(){ if(total! = "") total = total + ","; total = total + $(this).val(); }); $("#log"). Html(total + " is checked!").

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions