so i have this code which will not work for me:
javascript code:
[code] function toggle() {
var wrap= document.getElementById('wrap');
var modName=this.getAttribute('ModelName');
var spans=wrap.getElementsByTagName('span');
var spans_l=spans.length;
while (spans_l--){
span=spans[spans_l];
if(span.getAttribute('class')==modName){
var color= span.getAttribute('color');
span.style.background=color;
}
else{
div.style.background="white";
}
}
}[/code]
this acts on the following code:
[php] <?php
$seqA[]=“AAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBCCCCCCCCCCCC”;
$seqA[]=“BBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDD”;
$seqA[]=“CCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD”;
?>
<?php
//wont work with toggle function
foreach($seqA as $seq){
echo “<input ModelName=“ModelName"type=“checkbox”
onclick=“toggle.apply(this)” />show results”;
$score=rawtransform($raw);
$truecol= getcolor($score,220);
colorSequence($seq,5/hit/,$truecol,4);
echo”<hr style=“color:red”>";
}
?>
</form>
[php] function colorSequence ($seq,$position,$truecol,$TFBSlength){
$nucleotides = str_split($seq);
foreach ($nucleotides as $index => $nucl){
if ($index == $position-1){
echo “<span class=“selectedmodel” style=“background:white;“color=”$truecol”>”;
}
if ($index == $position + $TFBSlength){
echo “”;
}
if(($index%50)==0){
echo ‘
’;
}
echo $nucl;
}
echo "\n";
}[/php]
and getcolor
function: will give an output of hsl color.this will color a certain part of a sequence via inline styling.
my functions all work fine. Apart from the javascript. I want to be able to toggle the color on/off by clicking the checkbox. The color sequence colors a section of a sequence. Upon clicking the checkbox i want to change the background to white.
hope i explained my problem sufficiently.
Can anyone please help, racking my brains for an answer quite a while now.
thanks