Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help simplifying piece of code.

    Hi I am working on a site that uses javascript, but have not really done much with javascript before. I am sure there is a way to condense this script so that it isn't so bloated.

    http://www.cfwilson.com/RGI/NEW/V2V/V2V/viewer.js

    If someone could take a look at the code I have provided a link too and make a suggestion to point me in the right direction, or show me how to accomplish this that would be great.



    Thanks,
    Charles

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    Code:
    var lastID=0;
    	function SelectImg(id){
    		if (lastID > 0) {
    		document.getElementById(lastID).className="thumbNormal";
    		}
    		document.getElementById(id).className="thumbSelected";
    		document.getElementById(0).src=document.getElementById(id).src;
    		lastID=id;
            for (var zxc0=1;zxc0<=10;zxc0++){
      	    	document.getElementById("info_"+zxc0).style.visibility=(id==zxc0)?"visible":"hidden";
    			document.getElementById("info_"+zxc0).style.display=(id==zxc0)?"":"none";
     			document.getElementById("para1_"+zxc0).style.visibility=(id==zxc0)?"visible":"hidden";
    			document.getElementById("para1_"+zxc0).style.display=(id==zxc0)?"":"none";
    			document.getElementById("para2_"+zxc0).style.visibility=(id==zxc0)?"visible":"hidden";
    			document.getElementById("para2_"+zxc0).style.display=(id==zxc0)?"":"none";
    
            }
    }
    
    function LoadTrigger(){
     SelectImg(1);
    }
    
    window.onload=LoadTrigger;
    
    function window_onload() {
    
     for (var zxc0=1;zxc0<10;zxc0++){
    		document.getElementById("info_"+zxc0).style.visibility="hidden";
    		document.getElementById("info_"+zxc0).style.display="none";
    
     }
    		document.getElementById("info_1").style.visibility="visible";
    		document.getElementById("info_1").style.display="";
    }
    function thumbnail_onmouseover(id){
    	document.getElementById(id).style.cursor="hand";
    }
    function thumbnail_onmouseout(id){
    	document.getElementById(id).style.cursor="default";
    }
    //-->
    </script>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •