Results 1 to 2 of 2

Thread: how to show/hide buttons?

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Unhappy how to show/hide buttons?

    hi there!!
    i am making a gallery with chekboxes and i want to hide both buttons(with ids:'btn_next' and 'btn_prev') when i have less than my offset number but i can't make it..what i need to change in this code?it hides and shows my buttons only when i have more images than the offset..i call this function with 'changestep(0);'

    here is my code:

    Code:
    var step=0;
    var offset=6;
    
    function changestep(st)
    {
    	var len=images.length;
    	var maxsets=parseInt(len/offset);
    	
    	if (st==0) {
    		step=0;
    		maxsets=1;
    		update_tag();
    	}
    	else {
    		step=step+st;
    		if (step>maxsets) {
    			step=maxsets-1;
    		}
    		update_tag();
    	}
    	
    	//buttons display or not
    	if (step == 0) {
    		$('btn_prev').style.visibility='hidden';
    	} 
    	else {
    		if (step == (maxsets-1)) {
    			$('btn_next').style.visibility='hidden';
    			$('btn_prev').style.visibility='visible';
    		}
    		else {
    			$('btn_prev').style.visibility='visible';
    			$('btn_next').style.visibility='visible';
    		}
    	}
    	
    //alert('len:'+len+' offset:'+offset+' maxsets:'+maxsets+' step:'+step+' st:'+st);
    }
    please help me as fast as you can!!thanks!!
    Last edited by tpravioti; 01-18-2010 at 09:29 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Your offset number of what, images? If your images are image tags and are in a container with the id of, say - img_container:

    Code:
    If(document.getElementById('img_container').getElementsByTagName('img').length < 6){
    do whatever to hide the buttons
    }else{
    do whatever to show the buttons
    }
    Where do the checkboxes come in?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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