...

View Full Version : highlight row color



nikko50
10-22-2005, 06:27 PM
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>

vwphillips
10-22-2005, 10:03 PM
It is good manners to leave script credits intact!
especially if you need support



<!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>

nikko50
10-22-2005, 10:31 PM
Your the best:)
Tracy

canadianjameson
10-22-2005, 10:39 PM
hahaha

thats funny :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum