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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    311
    Thanks
    17
    Thanked 0 Times in 0 Posts

    set checkboxes.checked in array???

    Hey All,

    NEVER MIND, NOW IT WORKS

    Can this be done?
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function set_user_mass_flags(){
    flag = document.MassUpdate.flag;
    user=document.getElementById('currentUser');
    for(var i=0; i < document.MassUpdate.flag.length; i++){
    if(flag[i].value == user.value)
    
    //alert('hooray');
    //flag[i].checked; THIS WAS THE PROBLEM
    //NOW IT WORKS, Try it.
    flag[i].checked=true;
    }
    }
    window.onload = set_user_mass_flags;
    </script>
    </head>
    <body>
    <input type="hidden" name="currentUser" value="450f379a-f9d2">
    <form name="MassUpdate" id="MassUpdate">
    <input type="checkbox" name="flag" value='450f379a-f9d2'><br>
    <input type="checkbox" name="flag" value=''><br>
    <input type="checkbox" name="flag" value='450f379a-f9d2'><br>
    <input type="checkbox" name="flag" value=''><br>
    <input type="checkbox" name="flag" value='450f379a-f9d2'><br>
    </form>
    </body>
    </html>
    Last edited by fuzzy1; 05-06-2007 at 11:58 PM.

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    may i ask why you have that many checkboxes with the same name? you may be encountering a problem created due to this. 5 check boxes with the same name is like makign a group of radio buttons. doesnt matter what 4 of the 5 are set to, if only one is set to a value (true) then that value holds true for that whole group.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    Regular Coder
    Join Date
    Apr 2006
    Posts
    311
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Sure brandonH,
    You CAN ask.

    First -- given the realization that I needed to set flag[i].checked=true; instead of just flag[i].checked; -- let me just say PROBLEM SOLVED.

    As for your question "Why?"
    I'm dealing with the Contacts module in a contact management app.

    In context here, we're listing snapshot values for a given contact record
    stored in a mysql db table. (currently only about 5,000 records).

    There are numerous coulmns in this view and variable settings to return
    anywhere between 20, and 300 rows at a time, counted, filtered, sorted,
    and then pagenated as nec. Every field returned in a given collumn has the
    same name/id, but is populated with record specific data.
    {CONTACT_FIRST_NAME} for example.

    The field in question simply flags the record.
    (flagging for a mail merge would be just one example use.)

    Now, The flags are only visable -- and thereby
    useful to -- the users that create them! Neat Huh?

    Still, I am certain that I have used checbox.checked successfuly in the past?
    Or was that just a dream???

    p.s I also use many multples of radio buttons in much the same way.
    Last edited by fuzzy1; 05-06-2007 at 11:52 PM.


  •  

    Posting Permissions

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