Disable a button if slideshow is on slide #1

I have been searching how to disable a button if the slideshow is on slide #1.
I have made a slideshow but I want my navigation buttons to be on top right corner as little arrows, so I made two buttons and added a code:

export function button8_click ( event ) {
$w ( “#slideshow1” ). changeSlide ( 1 );
}
export function button10_click ( event ) {
$w ( “#slideshow1” ). changeSlide ( 0 );
}

This solwed the navigation between the two slides, but I want the button10 to be disabled when #slideshow1 is on the slide 0 (which is the first slide). Because the button10 does nothing on the slide #1 anyway.

Please help!

Your task should be easy…

Try this one…

$w.onReady(()=>{
	$w('#button8').onClick(()=>{
		$w("#slideshow1").changeSlide(1);}
		if($w("#slideshow1").currentSlide!==0) {$w('#button10').enable();}	
	});
	
	$w('#button10').onClick(()=>{
		$w("#slideshow1").changeSlide(0);}	
		if($w("#slideshow1").currentSlide===0) {$w('#button10').disable();}
	});
});

Replace your old code with the new one and give it a go :wink:

It’s giving me an error…

And this one is showing…

how do I fix?

I changed to this and it worked!

$w . onReady (()=>{
$w ( ‘#button8’ ). onClick (()=>{
$w ( “#slideshow1” ). changeSlide ( 1 );
if ( $w ( “#slideshow1” ). currentSlide !== 1 ) { $w ( ‘#button10’ ). enable ();}
});

$w ( '#button10' ). onClick (()=>{ 
    $w ( "#slideshow1" ). changeSlide ( 0 ); 
    **if** ( $w ( "#slideshow1" ). currentSlide !== 0 ) { $w ( '#button10' ). disable ();} 
}); 

});

But #button10 disables only after I click the #button8 to change to the second slide and then I click on the #button10 again. The #button10 is not disabled right at the start.
I guess its because of the . onClick and if

Now this one works perfectly like I need.
And I unchecked Enable for the the #button10

$w . onReady (()=>{
$w ( ‘#button8’ ). onClick (()=>{
$w ( “#slideshow1” ). changeSlide ( 1 );
if ( $w ( “#slideshow1” ). currentSlide !== 1 ) { $w ( ‘#button10’ ). enable ();}
if ( $w ( “#slideshow1” ). currentSlide !== 1 ) { $w ( ‘#button8’ ). disable ();}
});

$w ( '#button10' ). onClick (()=>{ 
    $w ( "#slideshow1" ). changeSlide ( 0 ); 
    **if** ( $w ( "#slideshow1" ). currentSlide !== 0 ) { $w ( '#button10' ). disable ();} 
    **if** ( $w ( "#slideshow1" ). currentSlide !== 1 ) { $w ( '#button8' ). enable ();} 
}); 

});

Sorry for the little bugs. Sometimes it happens when doing copy&paste proccesses to fast xD.

Also do a correction at this part…

if($w("#slideshow1").currentSlide!==0){$w('#button10').disable();}

Should be…

if($w("#slideshow1").currentSlide!===0){$w('#button10').disable();}

And next time use → CODE-BLOCk to show your code. Like i do! :wink:

hi!

you should change .currentSlide to .currentIndex in your code