PDA

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



tpravioti
01-12-2010, 08:19 PM
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: