javascript variables
<p>Im struggling with this script. It's all working fine but but i want to add a different error message when all 3 placeholders are true. I have tried but the alert kept coming up with every person chose instead of at the end or just not at all.
How do i do this?</p>

<p>Thanks</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;
&lt;/title&gt;
  &lt;script type="text/javascript" language="javascript"&gt;
var display = [ false, false, false ];
function showPic (whichpic) { 
    if (document.getElementById) { 
        try {
          if ((document.getElementById('placeholder0').src+
              document.getElementById('placeholder1').src+
              document.getElementById('placeholder2').src).search(whichpic.href) &gt; -1)
          throw "blah";


         var i;
            for(i=0; i&lt;=2; i++) {
            if (display[i]==false) {
                document.getElementById('placeholder'+ i).src = whichpic.href;
                display[i]=true;
                break;
            }
            }

          return false; 
        } catch(e) {
          alert("You have already selected this person");
          return false;
        }
    } else { 
        return true; 
    }
}
function removepic0(blank){

        document.getElementById('placeholder0').src = "images/blank.gif";
        display[0]=false;   
}
function removepic1(blank){

        document.getElementById('placeholder1').src = "images/blank.gif";
        display[1]=false;   

}
function removepic2(blank){

        document.getElementById('placeholder2').src = "images/blank.gif";
        display[2]=false;   
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div style="border: 1px solid #999; padding: 1em; margin: 0 0 15px 0;"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a onclick="return showPic(this)" href="images/1.jpg" title="img 1"&gt;Ted&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a onclick="return showPic(this)" href="images/2.jpg" title="img 2"&gt;John&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a onclick="return showPic(this)" href="images/3.jpg" title="img 3"&gt;Lewis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a onclick="return showPic(this)" href="images/4.jpg" title="img 4"&gt;Bill&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a onclick="return showPic(this)" href="images/5.jpg" title="img 5"&gt;Ben&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a onclick="return showPic(this)" href="images/6.jpg" title="img 6"&gt;Tom&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p id="desc"&gt;Choose an image to begin&lt;/p&gt;
&lt;img onclick="return removepic0(this)" id="advert" src="images/delete.gif" border="0"/&gt;
&lt;img id="placeholder0" src="images/blank.gif" alt="" /&gt;
&lt;img onclick="return removepic1(this)" id="advert" src="images/delete.gif" border="0"/&gt;
&lt;img id="placeholder1" src="images/blank.gif" alt="" /&gt;
&lt;img onclick="return removepic2(this)" id="advert" src="images/delete.gif" border="0"/&gt;
&lt;img id="placeholder2" src="images/blank.gif" alt="" /&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
