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 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts

    highlight row color

    Hello all. My highlight row color script worked until I added the checkbox validation script. Why does'nt it work now??
    <script language="JavaScript" type="text/javascript">
    // No Need to Change
    function f6_OneCheckBox(){
    f6_cbs=document.getElementsByTagName('INPUT');
    for (f6_0=0;f6_0<f6_cbs.length;f6_0++){
    if (f6_cbs[f6_0].title.substring(0,3)=='f6_'){
    f6_cbs[f6_0].onclick=function(){ f6_CheckOnlyOne(this); }
    }
    }
    }

    function f6_CheckOnlyOne(f6_){
    for (f6_0=0;f6_0<f6_cbs.length;f6_0++){
    if (f6_cbs[f6_0].title==f6_.title&&f6_cbs[f6_0]!=f6_){
    f6_cbs[f6_0].checked=false;
    }
    }
    }


    function highlightRow (el, color) {
    color=el.checked?color:'';
    while (el.tagName.toUpperCase() != 'TR' && el != null)
    el = el.parentNode;
    if (el)
    el.style.backgroundColor = color;
    }

    //-->
    </script>
    <body onload="f6_OneCheckBox()" >


    <form method="POST" action="--WEBBOT-SELF--">

    <table><tr>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group1" name="C2" value="ON"> </td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group1" name="C3" value="ON"></td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group1" name="C4" value="ON"></td></tr>
    <tr><td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group2" name="C2" value="ON"></td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group2" name="C3" value="ON"></td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group2" name="C4" value="ON"></td>
    </form>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    It is good manners to leave script credits intact!
    especially if you need support

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    </head>
    
    <body>
    <script language="JavaScript" type="text/javascript">
    // Form Compendium f6 (15-04-2005)
    
    // modified (22-10-2005)
    
    
    // One Check Box
    // by Vic Phillips http://www.vicsJavaScripts.org.uk
    
    // Simulating the function of radio buttons with the appearance of a check box
    
    // Application Note
    
    // Insert an onload event call in the &lt;body> tag
    // &lt;body onload="f6_OneCheckBox()" >
    
    // Give each check box in a group a title attribute
    // with common name prefixed with 'f6_'
    // eg
    // &lt;input title="f6_Group1" type="checkbox" name="ocbGroup1" checked="checked" >&lt;br>
    // &lt;input title="f6_Group1" type="checkbox" name="ocbGroup1" >&lt;br>
    // &lt;input title="f6_Group1" type="checkbox" name="ocbGroup1" >&lt;br>
    // &lt;input title="f6_Group1" type="checkbox" name="ocbGroup1" >&lt;br>
    // &lt;input title="f6_Group1" type="checkbox" name="ocbGroup1" >&lt;br>
    
    // All variable, function etc. names are prefixed with 'f6_' to minimise conflicts with other javascripts
    
    
    // No Need to Change
    function f6_OneCheckBox(){
    f6_cbs=document.getElementsByTagName('INPUT');
    for (f6_0=0;f6_0<f6_cbs.length;f6_0++){
    if (f6_cbs[f6_0].title.substring(0,3)=='f6_'){
    //f6_cbs[f6_0].onclick=function(){ f6_CheckOnlyOne(this); }
    zxcAddf6_CheckOnlyOne(f6_cbs[f6_0])}
    }
    }
    
    function f6_CheckOnlyOne(){
    for (f6_0=0;f6_0<f6_cbs.length;f6_0++){
    if (f6_cbs[f6_0].title==this.title&&f6_cbs[f6_0]!=this){
    f6_cbs[f6_0].checked=false;
    }
    }
    }
    
    function zxcEventAdd(zxco,zxct,zxcf) {
     if ( zxco.addEventListener ){ zxco.addEventListener(zxct, function(e){ zxco[zxcf](e);}, false); }
     else if ( zxco.attachEvent ){ zxco.attachEvent('on'+zxct,function(e){ zxco[zxcf](e); }); }
     else {
      var zxcPrev=zxco["on" + zxct];
      if (zxcPrev){ zxco['on'+zxct]=function(e){ zxcPrev(e); zxco[zxcf](e); }; }
      else { zxco['on'+zxct]=zxco[zxcf]; }
     }
    }
    
    function zxcAddf6_CheckOnlyOne(zxc){
     if (zxc.addf6_CheckOnlyOne){ return; }
     zxc.addf6_CheckOnlyOne=f6_CheckOnlyOne;
     zxcEventAdd(zxc,'click','addf6_CheckOnlyOne');
    }
    
    function highlightRow(el, color) {
    color=el.checked?color:'';
    while (el.tagName.toUpperCase() != 'TR' && el != null)
    el = el.parentNode;
    if (el)
    el.style.backgroundColor = color;
    }
    
    //-->
    </script>
    <body onload="f6_OneCheckBox()" >
    
    
    <form method="POST" action="--WEBBOT-SELF--">
    
    <table><tr>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group1" name="C2" value="ON"> </td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group1" name="C3" value="ON"></td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group1" name="C4" value="ON"></td></tr>
    <tr><td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group2" name="C2" value="ON"></td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group2" name="C3" value="ON"></td>
    <td><input type="checkbox" ONCLICK="highlightRow(this,'green');" title="f6_Group2" name="C4" value="ON"></td>
    </form>
    </body>
    
    </html>

  • #3
    Regular Coder
    Join Date
    May 2004
    Posts
    391
    Thanks
    76
    Thanked 0 Times in 0 Posts
    Your the best
    Tracy

  • #4
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    hahaha

    thats funny
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)


  •  

    Posting Permissions

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