# Button click to specific slide on another page

**URL:** <https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [June 14, 2020, 10:35am UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855 "2020-06-14T10:35:46Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 10:35am UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/1 "2020-06-14T10:35:46Z")

</div>

Hello,  
I am trying to clink to a specific slide, the button to press is on a different page. I have gone through past discussions but can’t find a solution for this specifically.

I feel like the following code is what I need (in part) but I am still learning it all and can’t piece it together to do what I want it to.

$w ( “#button36” ). onClick (( event ) =\> {  
$w ( “#slideshow1” ). next ();  
})

$w ( “#slideshow1” ). changeSlide (1);

Any help would be greatly appreciated, thanks.

---

<div class="post-metadata">

**Author:** ![ayleung66](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@ayleung66](https://forum.wixstudio.com/u/ayleung66)\
**Post date:** [June 14, 2020, 11:23am UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/2 "2020-06-14T11:23:48Z")

</div>

Hi, slide show usually comes with two buttons, “previousButton” and “nextButton”. Here is what actually needed:

$w ( " [#](https://www.wix.com/corvid/forum/search/~num~button36) previousButton " ). onClick (( event ) =\> {  
$w ( " [#slideshow1](https://www.wix.com/corvid/forum/search/~num~slideshow1) " ).previous();  
})

$w ( " [#](https://www.wix.com/corvid/forum/search/~num~button36) nextButton" ). onClick (( event ) =\> {  
$w ( " [#slideshow1](https://www.wix.com/corvid/forum/search/~num~slideshow1) " ). next ();  
})

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 11:38am UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/3 "2020-06-14T11:38:22Z")

</div>

Hi, I am not actually after a button to use on the slideshow, I am after a button that from a different page of my website will link to a specific slide.

For example the button on page two is called Property A and when pressed it takes you to slide 5 of the slide show on page one.

Or will that code work for this? Sorry for being a bit basic with my knowledge on this, thank you for your help.

---

<div class="post-metadata">

**Author:** ![ayleung66](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@ayleung66](https://forum.wixstudio.com/u/ayleung66)\
**Post date:** [June 14, 2020, 12:00pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/4 "2020-06-14T12:00:13Z")

</div>

Then use :

$w ( " [#](https://www.wix.com/corvid/forum/search/~num~button36) button36" ). onClick (( event ) =\> {  
$w ( " [#slideshow1](https://www.wix.com/corvid/forum/search/~num~slideshow1) " ). changeSlide ( index);  
})

And index start from zero, the first slide.

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 12:23pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/5 "2020-06-14T12:23:31Z")

</div>

Thank you, it still won’t connect it says that the line below is not a valid sector, is that because it’s not on the page I am adding the code to?

$w ( " [#slideshow1](https://www.wix.com/corvid/forum/search/~num~slideshow1) " ). changeSlide ( index);

---

<div class="post-metadata">

**Author:** ![ayleung66](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@ayleung66](https://forum.wixstudio.com/u/ayleung66)\
**Post date:** [June 14, 2020, 12:43pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/6 "2020-06-14T12:43:14Z")

</div>

That is actually what I think of too, it makes no sense to play the slide that is on other page. You have to be on the slide show page to select the slide to play. Basically, what you are doing is impossible.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 14, 2020, 12:50pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/7 "2020-06-14T12:50:18Z")

</div>

When you click the button, you can [save](https://www.wix.com/corvid/new-reference/wix-storage/storage/setitem) the slide number in [storage](https://www.wix.com/corvid/new-reference/wix-storage/storage/setitem) . Then, when you get to the other page, you can [get](https://www.wix.com/corvid/new-reference/wix-storage/storage/getitem) the slide number from [storage](https://www.wix.com/corvid/new-reference/wix-storage/storage/getitem) , and then changeSlide().

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 12:59pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/8 "2020-06-14T12:59:14Z")

</div>

Thank you, I will give it try and now see if I can get it linked up. Thanks!

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 1:12pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/9 "2020-06-14T13:12:22Z")

</div>

Hi Yisrael,

Sorry to ask again, but I must be doing something wrong here as I am still getting an error on the line $w( " #slideshow1 " ).changeSlide( 1 );

**On my slide show page I have:**

**import** {local} **from** ‘wix-storage’ ;  
// …  
local.setItem( “#slideshow1” , “Side(1)” );

**And on the button page I have:**

**import** {local} **from** ‘wix-storage’ ;  
// …  
**let** value = local.getItem( “#slideshow1” ); //

$w( “#button25” ).onClick((event)=\>{  
$w( “#slideshow1” ).changeSlide( 1 );  
})

Appreciate your help!

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 14, 2020, 1:36pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/10 "2020-06-14T13:36:36Z")

</div>

On the button page you need to save the slide number to be displayed, and then redirect to the slide page using the [wix-location](https://www.wix.com/corvid/new-reference/wix-location/to) API:

```javascript
$w("#button25").onClick((event)=>{
    local.setItem("slide-number", "1");
    wixLocation.to('/SlidePage');
}) 

```

On the slide page you need something like this:

```javascript
$w.onReady(function () {
    let num = local.getItem("slide-number");
    $w("#slideshow1").changeSlide(num);
});

```

To learn about programming with Corvid, read the following articles that will help you start working with Corvid:

- About Corvid by Wix - what Corvid is and what features it has.

- Getting Started with Corvid by Wix - step-by-step tutorial on how to start using Corvid.

- Onboarding to Corvid by Wix - introduction to Corvid with short tutorials.

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 1:46pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/11 "2020-06-14T13:46:24Z")

</div>

Thank you, and thanks for the links I have been getting through some of the tutorials - way more to go as you can probably tell!

I put in the code and have no errors, which is great but nothing happens when I press the button.

Button page code:  
import wixLocation from ‘wix-location’ ;  
import {local} from ‘wix-storage’ ;  
// …  
let value = local.getItem( “#slideshow1” ); //

$w( “#button25” ).onClick((event)=\>{  
local.setItem( “slide-number” , “1” );  
wixLocation.to( “/projects” );

})

Slideshow page code:  
import {local} from ‘wix-storage’ ;  
// …  
local.setItem( “#slideshow1” );  
$w.onReady( function () {  
let num = local.getItem( “slide-number” );  
$w( “#slideshow1” ).changeSlide(num);  
});

I don’t know if it will help but this is the web page that I want the button to work from [https://gtd-websites.wixsite.com/hjcollection/developments-map](https://gtd-websites.wixsite.com/hjcollection/developments-map) and for it to connect to the relevant slide show at the bottom of this page [https://gtd-websites.wixsite.com/hjcollection/projects](https://gtd-websites.wixsite.com/hjcollection/projects)

Thanks again!

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 14, 2020, 2:00pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/12 "2020-06-14T14:00:30Z")

</div>

Button page:

```javascript
import wixLocation from 'wix-location';
import { local } from 'wix-storage';

$w.onReady(function () {
    $w("#button25").onClick((event) => {
        console.log('click');
        local.setItem("slide-number", "1");
        wixLocation.to("/projects");
    })
});

```

Slideshow page:

```javascript
import {local} from 'wix-storage';

$w.onReady(function () {
   let num = Number(local.getItem("slide-number"));
   $w("#slideshow1").changeSlide(num);
});

```

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 2:22pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/13 "2020-06-14T14:22:24Z")

</div>

Yay thank you! It works! I just need to get it to take me to the part of the page that displays the slideshow as it currently just takes me to the projects page and the right slide but not directly to the part of the page where the slide is.

I don’t know if this would even be possible as I couldn’t link to anchors like this before?

Sorry and thank you!

---

<div class="post-metadata">

**Author:** ![ayleung66](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@ayleung66](https://forum.wixstudio.com/u/ayleung66)\
**Post date:** [June 14, 2020, 3:11pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/14 "2020-06-14T15:11:01Z")

</div>

Sorry, [Alexandra Hebden](https://www.wix.com/corvid/profile/9452517b-b1e6-4d59-b1b4-a6c5af028013) , I misunderstood the requirement. You want the button to take you to the slide page to play slide, not just stay in the page and change the slide to play.

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 3:22pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/15 "2020-06-14T15:22:00Z")

</div>

Yes exactly! Yisrael has been a massive help and I can now go from page one button to page two which has the slideshow on it and the right slide loads, but it doesn’t take me down the page to the slideshow it just takes me to the top of page two, so I am still trying to work out how I would do that…

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [June 14, 2020, 3:23pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/16 "2020-06-14T15:23:19Z")

</div>

Instead of this:

```javascript
wixLocation.to("/projects"); 

```

use this:

```javascript
wixLocation.to("/projects#slideshow1");

```

---

<div class="post-metadata">

**Author:** ![ahebden](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ahebden/32/20202_2.png) [@ahebden](https://forum.wixstudio.com/u/ahebden)\
**Post date:** [June 14, 2020, 3:32pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/17 "2020-06-14T15:32:59Z")

</div>

Legendary! Thank you so much for your help today. I will be diving more in to the tutorials and getting a better head for Corvid.

Thanks Yisrael!!

---

<div class="post-metadata">

**Author:** ![ruth\_k17](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ruth_k17/32/30827_2.png) [@ruth\_k17](https://forum.wixstudio.com/u/ruth_k17)\
**Post date:** [November 24, 2021, 8:00pm UTC](https://forum.wixstudio.com/t/button-click-to-specific-slide-on-another-page/18855/18 "2021-11-24T20:00:15Z")

</div>

Hi Israel, @yisrael-wix  
I used your code. But I still have not been able to solve to the end.  
My site has a “Studies” page - which can also be accessed from the “Studies” top menu. And also in the fourth strip entitled “Studies” from the home page.

But on the “Studies” page itself, I divided it into “Courses” and “Workshops” by 2 buttons on the page that are above the slider that changes according to the click. (And also in their color)

Now, in the home page on the “Studies” strip, I also divided it into 2 “Workshops” and “Courses” boxes, and each box has a dedicated button that should lead to the “Studies” page into the correct slider. (“Courses” / “Workshops”)

So I made your code, but my problem now is that the “Studies” page in this top menu goes to the “Workshops” slide (sometimes, depending on whether you already clicked on the “Workshops” button on the home page)  
In addition, according to the buttons on the “Studies” page (above the slider) it is on “Courses” (the button appears in pink)

I would really, really appreciate it if you could help me solve the code.  
It will really save me in front of the customer.

**Website link:**  
[https://www.art-meaning.com/](https://www.art-meaning.com/)

**Link to study page:**  
[https://www.art-meaning.com/studies](https://www.art-meaning.com/studies)

**A photograph of the “Studies” strip on the home page, which is divided into 2 boxes:**

 ![](https://us1.discourse-cdn.com/wix/original/3X/5/5/55085775df29e07c68a8b06b2d785b21e5cf2f07.jpeg)

**The code I have on the home page (where the buttons are on the strip):**

$w . onReady ( function () {  
// Write your JavaScript here

```
// To select an element by ID use: $w('#elementID') 

// Click 'Preview' to run your code 

```

});

import wixLocation from ‘wix-location’ ;  
import { local } from ‘wix-storage’ ;

$w . onReady ( function () {  
$w ( “#button25” ). onClick (( event ) =\> {  
console . log ( ‘click’ );  
local . setItem ( “slide-number” , “1” );  
wixLocation . to ( “/studies#fullWidthSlides1” );  
})  
});

$w . onReady ( function () {  
$w ( “#button6” ). onClick (( event ) =\> {  
console . log ( ‘click’ );  
local . setItem ( “slide-number” , “0” );  
wixLocation . to ( “/studies#fullWidthSlides1” );  
})  
});

**The code on the “Studies” page (where the slider is with the extra buttons above it):**

$w . onReady ( function () {  
//TODO: write your page related code here…  
});

export function secondButton\_click ( event , $w ) {  
$w ( “#fullWidthSlides1” ). changeSlide ( 1 );  
$w ( “#secondButton” ). style . backgroundColor = “#B7B7DB” ;  
let bgColor = $w ( “#secondButton” ). style . backgroundColor ;  
$w ( “#secondButton” ). style . color = “#DE6BB9” ;

$w ( “#firstButton” ). style . backgroundColor = “#003C3C” ;  
$w ( “#firstButton” ). style . color = “#B7B7DB” ;

$w ( “#thirdButton” ). style . backgroundColor = “#003C3C” ;  
$w ( “#thirdButton” ). style . color = “#B7B7DB” ;

}

export function firstButton\_click ( event , $w ) {  
$w ( “#fullWidthSlides1” ). changeSlide ( 0 );  
$w ( “#firstButton” ). style . backgroundColor = “#B7B7DB” ;  
let bgColor = $w ( “#firstButton” ). style . backgroundColor ;  
$w ( “#firstButton” ). style . color = “#DE6BB9” ;

$w ( “#secondButton” ). style . backgroundColor = “#003C3C” ;  
$w ( “#secondButton” ). style . color = “#B7B7DB” ;

$w ( “#thirdButton” ). style . backgroundColor = “#003C3C” ;  
$w ( “#thirdButton” ). style . color = “#B7B7DB” ;

}

export function thirdButton\_click ( event , $w ) {  
$w ( “#fullWidthSlides1” ). changeSlide ( 2 );  
$w ( “#thirdButton” ). style . backgroundColor = “#B7B7DB” ;  
let bgColor = $w ( “#thirdButton” ). style . backgroundColor ;  
$w ( “#thirdButton” ). style . color = “#DE6BB9” ;

$w ( “#firstButton” ). style . backgroundColor = “#003C3C” ;  
$w ( “#firstButton” ). style . color = “#B7B7DB” ;

$w ( “#secondButton” ). style . backgroundColor = “#003C3C” ;  
$w ( “#secondButton” ). style . color = “#B7B7DB” ;

}

export function downButtonDay2\_click ( event , $w ) {  
$w ( “#fullWidthSlides1” ). changeSlide ( 1 );  
}

export function downButtonDay1\_click ( event , $w ) {  
$w ( “#fullWidthSlides1” ). changeSlide ( 0 );  
}

import { local } from ‘wix-storage’ ;

$w . onReady ( function () {  
let num = Number ( local . getItem ( “slide-number” ));  
$w ( “#fullWidthSlides1” ). changeSlide ( num );  
});
