User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 28 Mar 2007, 20:27   #1
wu_trax
Registered User
 
Join Date: Jan 2003
Posts: 4,290
wu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet societywu_trax is a pillar of this Internet society
more annyoing javascript :(

I really dont get along with this stuff:
Code:
<script language="JavaScript">
  <!--
		function clipLogo(val) {
			var clip = new Array();
		
			clip.push("65306");
			clip.push("93535");
			clip.push("88757");
			clip.push("62455");
			clip.push("98673");
			clip.push("13907");
			for(var i=0;i<clip.length;i++) {
				if(clip[i] == val){
					if(document.getElementById("c" + val)){
						alert("c" + val);
					}
					document.getElementById("c" + val).style.display = "";
				}else{
					document.getElementById("c" + val).style.display = "none";
				}
			}
		}
	-->
</script>
<table class="formelement" border="0" cellpadding="2" cellspacing="1">
  <tr class="frmhandler_title">
    <td class="bold">Clip Logo</td>
  </tr>
  <tr bgcolor="#ECEEF6">

    <td class="normal" bgcolor="#FFFFFF" height="85">
      <div style="display:none;" id="c65306"><img src="/msd/imagepool/65306_medium.gif"></div>
      <div style="display:none;" id="c93535"><img src="/msd/imagepool/93535_medium.gif"></div>
      <div style="display:none;" id="c88757"><img src="/msd/imagepool/88757_medium.gif"></div>
      <div style="display:none;" id="c62455"><img src="/msd/imagepool/62455_medium.gif"></div>
      <div style="display:none;" id="c98673"><img src="/msd/imagepool/98673_medium.gif"></div>
      <div style="display:none;" id="c13907"><img src="/msd/imagepool/13907_medium.gif"></div>
    </td>
  </tr>

</table>
The idea is to show a different gif, depending on some user interaction, and that without a page reload.
This doesnt work, for some strange reason. Up to the alert() everything is fine. val does have the right value. If I pick the last item, I see it, but all the others i dont. Also once ive picked the last item it wont disappear after i picked another one.
Apparently the images are above each other with the last one being on top and blocking all others.
how do i fix this? It used to work, up until I started making some changes to this really ugly code.
__________________
im not tolerant, i just dont care.
wu_trax is offline   Reply With Quote
Unread 28 Mar 2007, 21:49   #2
Phil^
Insomniac
 
Phil^'s Avatar
 
Join Date: May 2003
Posts: 3,583
Phil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus wouldPhil^ spreads love and joy to the forum in the same way Jesus would
Re: more annyoing javascript :(

Code:
<html>
<script language="JavaScript">
  <!--
        function clipLogo(val) {
            var clip = new Array();
            clip.push("65306");
            clip.push("93535");
            clip.push("88757");
            clip.push("62455");
            clip.push("98673");
            clip.push("13907");
            
            for ( var i=0;i<clip.length;i++ ) {
            var elemid = "c" + clip[i];
                if ( clip[i] == val ) {
                        document.getElementById(elemid).style.display = "block";
                }
                else {
                    document.getElementById(elemid).style.display = "none";
                }
            }
        }
    -->
</script>
<body>

<table class="formelement" border="0" cellpadding="2" cellspacing="1">
  <tr class="frmhandler_title">
    <td class="bold">Clip Logo</td>
  </tr>
  <tr bgcolor="#ECEEF6">

    <td class="normal" bgcolor="#FFFFFF" height="85">
      <div id="c65306"> <img src="/msd/imagepool/65306_medium.gif"></div>
      <div id="c93535"><img src="/msd/imagepool/93535_medium.gif"></div>
      <div id="c88757"><img src="/msd/imagepool/88757_medium.gif"></div>
      <div id="c62455"><img src="/msd/imagepool/62455_medium.gif"></div>
      <div id="c98673"><img src="/msd/imagepool/98673_medium.gif"></div>
      <div id="c13907"><img src="/msd/imagepool/13907_medium.gif"></div>
    </td>
  </tr>
  <script language="JavaScript">
  <!--
  clipLogo(13907);
  -->
  </script>
  

</table>
</body>
</html>
You got mixed up with the element you wanted, and the element in the loop
Also the setting of the display was outside of the if block which controlled when to do it
__________________
Phil^
Phil^ is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 13:25.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018