SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot Conspiracy's Avatar
    Join Date
    May 2002
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looking for a highlight and checkbox script

    I have some, but they are very long and complicated for my brain and not quite what I need.
    I am looking for a script, like in a mailbox, that when you check, the row of a table changes the colour (but it has to be on a input level, I can't have tags with ID or things like that on the TR/TD). And on top of that, this script should also check/uncheck all (those little boxes on the Thead of the table that when you tick, tick all checkboxes or uncheck them!

    Thanks in advance!

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Difficult to uderstand your post but these snippets may help

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--

    function 
    CheckBox(state){
     
    ipObj=document.getElementsByTagName('INPUT');
     for (
    i=0;i<ipObj.length;i++){
      if (
    ipObj[i].type=='checkbox'){
       
    ipObj[i].checked=state;
      }
     }
    }

    //-->
    </script>
    </head>

    <body>
    <br>
    I have some, but they are very long and complicated for my brain and not quite what I need.<br>
    <br>
    I am looking for a script, like in a mailbox, that when you check,<br>
     the row of a table changes the colour (but it has to be on a input level,<br>
      I can't have tags with ID or things like that on the TR/TD).<br>
      <br> And on top of that,
      <br> this script should also check/uncheck all<br>
       (those little boxes on the Thead of the table that when you tick, tick all checkboxes or uncheck them!
    <br>
    <input type="checkbox" name="" checked="checked"><br>
    <input type="checkbox" name="" checked="checked"><br>
    <input type="checkbox" name="" checked="checked"><br>
    <input type="checkbox" name="" checked="checked"><br>
    <input type="checkbox" name="" checked="checked"><br>
    <input type="button" name="" value="CheckBox = true" onclick="CheckBox(true);" ><br>
    <input type="button" name="" value="CheckBox = false" onclick="CheckBox(false);"><br>
    </body>

    </html> 
    PHP Code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    CngColor(cc,col){
    cc.oldcol=cc.style.backgroundColor;
    cc.style.backgroundColor=col;
    cc.onmouseout=function(){ this.style.backgroundColor=this.oldcol; }
    }

    //-->
    </script>
    </head>

    <body>
    <table width="200" height="100" border="1">
      <tr>
        <td onmouseover="javascript:CngColor(this,'blue');" >.</td>
        <td onmouseover="javascript:CngColor(this,'green');" >.</td>
      </tr>
      <tr>
        <td bgcolor=blue onmouseover="javascript:CngColor(this,'yellow');">.</td>
        <td onmouseover="javascript:CngColor(this,'red');">.</td>
      </tr>
    </table>
    <input type="button" name="" value="Button 1" onmouseover="javascript:CngColor(this,'blue');"><br>
    <input type="button" name="" value="Button 1" onmouseover="javascript:CngColor(this,'green');"><br>
    <input type="button" name="" value="Button 1" onmouseover="javascript:CngColor(this,'yellow');"><br>
    <input type="button" name="" value="Button 1" onmouseover="javascript:CngColor(this,'red');"><br>
    <input type="button" name="" value="Button 1" onmouseover="javascript:CngColor(this,'white');"><br>
    </body>

    </html> 

  3. #3
    SitePoint Zealot Conspiracy's Avatar
    Join Date
    May 2002
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying, but what I had in mind was something a bit different. I have a table and the first column is just checkboxes, what I wanted was the top checkbox, when clicked, would get all checkboxes checked and unchecked. And at the same time, when you tick a checkbox, the background of that row chances, to call the persons attention that that row/rows were checked. I'm sure I could merge those two scripts your wrote to me somehow, but I really have no idea how....

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont understand

    what I wanted was the top checkbox, when clicked,would get all checkboxes checked and unchecked.
    what do you want doing when you get them, put in an array? or what

    PHP Code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    function 
    ChgColor(chg){
     
    P1=chg.parentNode;
     
    P2=P1.parentNode;
     if (
    chg.checked==true){
      
    P2.style.backgroundColor='red';
     }
     else {
      
    P2.style.backgroundColor='';
     }
    }
    //-->
    </script>

    </head>

    <body>
    And at the same time, when you tick a checkbox,<br>
     the background of that row chances, to call the persons attention that that row/rows were checked.<br>
    I'm sure I could merge those two scripts your wrote to me somehow, but I really have no idea how....

    <table width="300" border="1">
      <tr height=20 >
        <td width=50 ><input type="checkbox" name="" onclick="ChgColor(this);" ></td>
        <td width=250 >&nbsp;</td>
      </tr>
      <tr height=20 >
        <td width=50 ><input type="checkbox" name="" onclick="ChgColor(this);" ></td>
        <td width=250 >&nbsp;</td>
      </tr>
      <tr height=20 >
        <td width=50 ><input type="checkbox" name="" onclick="ChgColor(this);" ></td>
        <td width=250 >&nbsp;</td>
      </tr>
    </table>



    </body>

    </html> 


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
  •