Hey Guys,

been fighting with few lines of code for the last half hour and I am about to explode:
I have this little function:
Code:
function showImg(activ, no) {

      for (x = 0; x <= no; x++)  {
        document.getElementById('pf'+x).className = 'toggleHide';
      }
      
    document.getElementById('pf' + activ).className = 'toggleShow';
}
and when a link is clicked (which should hide all the divs at first and then show only the current one = I know it's primitive but I am no js programmer at all!!) the error console tells me "document.getElementById('pf'+x) is null".
What am I doing wrong?

when I specify the instances, one by one
Code:
  document.getElementById('pf1').className = 'toggleHide';
  document.getElementById('pf2').className = 'toggleHide';
  document.getElementById('pf3').className = 'toggleHide';
  document.getElementById('pf4').className = 'toggleHide';
  document.getElementById('pf5').className = 'toggleHide';
  
  document.getElementById('pf'+activ).className = 'toggleShow';
everything works just fine.

Any help?

Thank you in advance!

Cheers,
Greg