0

For example I have 5 checkboxes and all of them have same name. I check checkboxes, submit and then delete checkboxes I checked. Here I don´t have any problems, the problem it´s check for example the number 1 , 3 , 5 , etc , but has the same name and when check one uncheck other

How it´s possible check all checbox i want from for example 5 checboxes

For example :

Check 1 - checked
Check 2 - unchecked
Check 3 - checked
Check 4 - unchecked
Check 5 - checked

Thank´s Regards

2
  • 1
    Set up a fiddle for this. Ans post what you've tried. Commented Sep 13, 2012 at 11:01
  • and i want - for delete i check - send and delete the checkboxes i check , for this i haven´t problem Can you elaborate? please. Commented Sep 13, 2012 at 11:05

3 Answers 3

4

If you really can't give them different names or id and you want to check them all :

$('input[name="thename"]').prop('checked', true);

If you want to check the first, the third and the fifth checkbox, you can do this :

$('input[name="thename"]').filter(':eq(0), :eq(2), :eq(4)').prop('checked', true);
Sign up to request clarification or add additional context in comments.

3 Comments

I'm not sure about what OP wants. Maybe this answer will disappear next time I re-re-reread the question.
The question it´s easy , you have 5 checkbox with same name how i can do multiple select for example check 1 , 3 and 3 , if have the same name i can´t but it´s possible check multiple checkbox with the same name ..... ?
How do you decide what checkboxes to check ?
2

use id's to identify them individually:

<input type='checkbox' name='name' id='cb_1'/>
<input type='checkbox' name='name' id='cb_2'/>
<input type='checkbox' name='name' id='cb_3'/>
<input type='checkbox' name='name' id='cb_4'/>
<input type='checkbox' name='name' id='cb_5'/>

2 Comments

Yes but the problem it´s how i can select and unselect from for example 5 checkbox , the question it´s what i need for can check or uncheck from 5 for example 3 if have the same name
@Fran, I just told you how to, don't be scared to do a bit of research, I gave you all that you needed for this question :)
0

If you want to delete checkbox you check then this could help if you use jQuery

1 <input type='checkbox' name='my_name' /><br>
2 <input type='checkbox' name='my_name' /><br>
3 <input type='checkbox' name='my_name' /><br>
4 <input type='checkbox' name='my_name' /><br>
5 <input type='checkbox' name='my_name' /><br>
    <script type="text/javascript">​
        // Event handler activates when value of input with specified name is changed
        $("input[name=my_name]").on("change", function(event) {
            // checks if checkbox was checked, if so - deletes it
            if (true === $(this).prop('checked')) $(this).remove();
        });​
    </script>

http://jsfiddle.net/56nBw/1/

1 Comment

Ahahaha... this would help a little if you used ajax :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.