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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts

    simple modification

    PHP Code:
    function checkall(formname,checkname,thestate){
    var 
    el_collection=eval("document.forms."+formname+"."+checkname)
    for (
    c=0;c<el_collection.length;c++)
    el_collection[c].checked=thestate 
    this code checkall radio buttons or checkbox by "name" attribute but I want to that code works by ID attribute. Can somebody make a modification for this?

    Regards

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    unlike the name attribute, the id must be unique on page/session. So that you may not have a group of radio buttons with the same id.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts
    This does not work, only works with the tag name


    Source: http://javascriptkit.com/script/script2/checkall.shtml

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I don't understand what you say. Once again, id must be unique.

    What do you want, in fact. What that code should do? can u detail?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Description: A good addition to your forms if they contain a multitude of check/radio buttons is a "check/uncheck all" feature. This script does just that for any group of checkboxes and radio buttons. Useful!

    IMPLEMENTATION: The first parameter should contain the name of your form, the second the common name of checkboxes you're grouping together, and lastly, whether they should be checked or unchecked (pass true for former).

    FOR MORE DETAILS:
    http://javascriptkit.com/script/script2/checkall.shtml

    Regards

  • #6
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Solved
    Last edited by urgido; 10-21-2006 at 09:40 AM.

  • #7
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,086
    Thanks
    38
    Thanked 498 Times in 492 Posts
    And your solution is?
    If it is so useful, why not share it?


  •  

    Posting Permissions

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