SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sellect all checkboxes and inverse selection

    I have this table with all my values I want to check and inverse

    HTML Code:
    <input type=text name="set_name" value="" maxlength=255 size="50"><br><br>
    <input type=submit value="Submit"> <input type=reset value="Reset"><br><br>
    Select members belonging to this set.<br>
    <input type=button value="Check All" onClick="this.value=check(this.form.set_member\[\])"> 
    <table>
    <td><input type=checkbox name="set_member[]" value="77"> Adam Green</td>
    <td><input type=checkbox name="set_member[]" value="70"> Brenton Rzepecki</td>
    <td><input type=checkbox name="set_member[]" value="94"> Brett Stayt</td>
    <td><input type=checkbox name="set_member[]" value="63"> Brock Wallis</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="102"> Chris Cornish</td>
    <td><input type=checkbox name="set_member[]" value="68"> Dale Smulders</td>
    <td><input type=checkbox name="set_member[]" value="114"> Damian Astone</td>
    <td><input type=checkbox name="set_member[]" value="106"> Dave Chang</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="101"> David Waldron</td>
    <td><input type=checkbox name="set_member[]" value="84"> Doug Thomson</td>
    <td><input type=checkbox name="set_member[]" value="108"> Gary Bruecher</td>
    <td><input type=checkbox name="set_member[]" value="87"> Gerald Delic</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="104"> Gordon Hay</td>
    <td><input type=checkbox name="set_member[]" value="86"> Jamie Vw</td>
    <td><input type=checkbox name="set_member[]" value="99"> Jim Felvus</td>
    <td><input type=checkbox name="set_member[]" value="88"> Jordan Masters</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="71"> Josh P</td>
    <td><input type=checkbox name="set_member[]" value="89"> Josh Taylor</td>
    <td><input type=checkbox name="set_member[]" value="96"> Karis Putland</td>
    <td><input type=checkbox name="set_member[]" value="116"> Kevin Craig</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="65"> Kyle Putland</td>
    <td><input type=checkbox name="set_member[]" value="73"> Logan Bruecher</td>
    <td><input type=checkbox name="set_member[]" value="118"> Michael Newson</td>
    <td><input type=checkbox name="set_member[]" value="110"> Mike Nyman</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="85"> Mitch Virlee</td>
    <td><input type=checkbox name="set_member[]" value="54"> Nathan Rzepecki</td>
    <td><input type=checkbox name="set_member[]" value="75"> Patrick Green-Mackinlay</td>
    <td><input type=checkbox name="set_member[]" value="83"> Patryk S</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="93"> Paul Smith</td>
    <td><input type=checkbox name="set_member[]" value="113"> Peter Needham</td>
    <td><input type=checkbox name="set_member[]" value="90"> Ricardo Velazquez</td>
    <td><input type=checkbox name="set_member[]" value="109"> Rick Penlington</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="111"> Rik Christiansen</td>
    <td><input type=checkbox name="set_member[]" value="69"> Rob Ralston</td>
    <td><input type=checkbox name="set_member[]" value="91"> Rohan Martin</td>
    <td><input type=checkbox name="set_member[]" value="107"> Samuel Silvestro</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="97"> Scott Kerenyi</td>
    <td><input type=checkbox name="set_member[]" value="56"> Steve Smulders</td>
    <td><input type=checkbox name="set_member[]" value="92"> Steve Pugh</td>
    <td><input type=checkbox name="set_member[]" value="103"> Stewart Whitson</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="100"> Stuart Moss</td>
    <td><input type=checkbox name="set_member[]" value="112"> Stuart Broom</td>
    <td><input type=checkbox name="set_member[]" value="76"> Suhud Simbolon</td>
    <td><input type=checkbox name="set_member[]" value="74"> Tim Muhl</td>
    </tr>
    <tr>
    <td><input type=checkbox name="set_member[]" value="115"> Toby Reeve</td>
    <td><input type=checkbox name="set_member[]" value="98"> William Reynolds</td>

    this is the javascript im using
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var checkflag = "false";
    function check(field) {
    if (checkflag == "false") {
    for (i = 0; i < field.length; i++) {
      field[i].checked = true;}
      checkflag = "true";
    return "Uncheck All"; }
    else {
    for (i = 0; i < field.length; i++) {
      field[i].checked = false; }
      checkflag = "false";
      return "Check All"; }
    }
    //  End -->
    </script>
    But I keep getting this error

    Code:
    Event thread: onclick
    Error:
    name: TypeError
    message: Statement on line 6: Expression evaluated to null or undefined and is not convertible to Object: field
    Backtrace:
      Line 6 of inline#1 script in http://radiorally.homelinux.net/goto/add_mass_email_set
        for (i = 0; i < field.length; i++)
      In unknown script
        this.value = check(this.form.set_member);
      At unknown location
        {event handler trampoline}
    
    
    Event thread: onclick
    Error:
    name: TypeError
    message: Statement on line 6: Expression evaluated to null or undefined and is not convertible to Object: field
    Backtrace:
      Line 6 of inline#1 script in http://radiorally.homelinux.net/goto/add_mass_email_set
        for (i = 0; i < field.length; i++)
      In unknown script
        this.value = check(this.form.set_member);
      At unknown location
        {event handler trampoline}
    Can anyone help me sort this out? Why is it throwing this error?

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check(this.form.set_member\[\])

    should be

    check(this.form["set_member[]"])

  3. #3
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did that but it didn't make a difference.


Bookmarks

Posting Permissions

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