PDA

View Full Version : Resolved how to show/hide buttons?



tpravioti
01-15-2010, 09:41 AM
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:



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!!:confused:

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


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?