Hello Everyone,
I have a trip website. So on page 1 I have a drop-down with each month of the year. when the user select a specific month, the available trips appear.
Now, I need to make page 2. On this page, there will be more details about the specific trip the user chose in the previous page, as well as another drop-down with month of each year. This way if he decides to check other dates for this trip, he does not have to go back to page 1 again. Makes sense, right?
My problem is, how do I make the default month selection on page 2 be the selected month from page 1?
So for example, on page 1 you select November 2020, You see a nice trip to the maldives. You then click on the trip button, which will take you to page 2 with details about this trip.
Right now, When he goes to page 2, he must re-select the month again (which is not so nice). I want the page 2 drop-down to load and show November 2020, with also the option to change it.
Thanks in advance.
Just make it manually, so for example on page one on your learn more button
Page 1
onReady->
onButtonClick(evet) ->
make a GET to determine the url of next item (id //is withn event -> target)
let newUrl = url+"?selectedMonth="+month
wixLocation.to(newUrl)
Page 2
onReady →
let query = wixWindow.query (make sure to import it)
if(query) { var selectedMonth = query.seleectedMonth }
$w(Page2dropdown).value = selectedMonth
Hello @carlos-alvarez
Sorry I just saw your reply, for some reason did not get any notification.
I kinda feel like what you’re saying is what I want. But I have to admit I don’t fully understand it.
I understand that on Page 1, I have to import the wix-location in order to add it to the onButtonClick event, and it takes me to a URL. I also understand that I will manually update the URL with the newURL thing.
But I do not know what I should add under the onButtonClick function, and how to set the selectedMonth, how to make it get the month from the one selected in the dropdown
Another option would be to use wix-storage to save the input values so that they are available to the other pages. For example:
// on all of the pages you will need this import statement:
import {session} from 'wix-storage';
// on page one, save a selected value like this:
let selected_month = $w("#dropdown").value;
session.setItem("month", selected_month);
// on page two, retrieve the value from page one like this:
let value = session.getItem("month");
Using wix-storage, you can store all of the values from your pages and have them available for use wherever you want.
Hey @yisrael-wix
this is actually the first thing I thought about doing, but had no idea how to make it work. Now it’s perfect and working perfectly.
Is there a way to mix and match what you said with what Carlos said above? so that for example, let’s assume my page 1 url is www.thediverslog.com/maldives
I want the url to be updated everytime the user changes the dropdown date while browsing for trips. so when they select for example March 2020, the url would be something like www.[…]/maldives/march2020 or something like that.
This way, if they which to copy the link for a specific month or trip, they can copy and send it to friend ti check.
from what i understood about Carlos’ input, that the query would do that, but I have a hard time understanding how to make it work.
Thanks for your help
Hi @Yisrael (Wix)
How do you achieve this the other way around?
1st page click a button 1, 2, 3, 4, 5, 6 etc
2nd page default drop down to the button value
I’m struggling
@grantwardle97 What are you struggling with? Please add your own issue into a new post instead of bumping up an old post. Explain what you are trying to do, what works, and what doesn’t. Also, add any code in a code block as stated in the Forum Guidelines .
This is an old post and is being closed.