PDA

View Full Version : form change font color within span when numer match is true



boemboem
08-12-2009, 09:25 PM
Hello all, I'm totally new to this forum, My name is Chris from the Netherlands. I'm trying to lern javascript, but my knowledge doesn't cover what I want, so I could really use some help. I'm trying to make a lotto check form for our family.

Can somebody explain me how to alter this code to color the font green even if the match isn't on the same place, please take a look at this image, it explains more then 1000 words.

Here is an example, don't mind the banner, it's a family joke, so nothing commercial. :D it only works in IE at the moment.

http://www.coldcharlie.nl/lotto.html


<SCRIPT TYPE="TEXT/JAVASCRIPT">
// Check lotto

function checkLotto() {
var goed = frmTrekking.Getal
var fout = frmGetallen.Opgegeven
for (var z0=0;z0<goed.length;z0++){
if (goed[z0]&&fout[z0]){
if (goed[z0].value==fout[z0].value){
fout[z0].parentNode.style.color='#00FF00';
fout[z0].parentNode.getElementsByTagName('SPAN')[0].innerHTML+=goed[z0].value;
}
else {
fout[z0].parentNode.style.color='#cc0000';
fout[z0].parentNode.getElementsByTagName('SPAN')[0].innerHTML+=fout[z0].value;

}
}
}

}

</script>

Beneath is a graphical explaination, I really hopes this helps.


http://www.imagedump.nl/img148/851/64lotto.th.jpg (http://www.imagedump.nl/img148/851/64lotto.jpg)

boemboem
08-14-2009, 08:20 AM
Can anyone help me?