Is it possible to have a dropdown option selected based on the page the user is coming from?

I have 3-4 pages that link to a page with a form on it. Is it possible to pre-select an answer from a dropdown box in the form based on which of those pages the user came from.

Furthermore, is it possible to change the placeholder text of a paragraph field in the same form based on the selection of the dropbox field.

You can get the path of the referring page and then use that to change your dropdown.

See the docs on the text input’s placeholder property.

Hey Yisrael, thanks for your response. The “path” page you have linked to doesn’t really mention how to get the path of the previous page.

@itsdjkcofficial Oh - for cryin’ out loud - that’s ridiculous! I hate it when I’m stupid. Answered a bit too quickly.

Two options:

You can use wix-storage . On the first page, save a value to identify the page using setItem() . Then on the target page that you are redirecting to, use getItem() to retrieve the identifier of the page that we came from.

The other was is to add a query to the URL when you redirect. The query will pass an identifier to the target page, and you can then retrieve the query using wix-location.query .

So I tried using the wix-storage method.
I’m assuming the code would look something like this for the first page.

import {session} from 'wix-storage';
export function button2_click(event) {
    session.setItem("key1", "Beats");
    $w("#button2").link = "/contact";
    console.log("success");
}

But for some reason when I click the button it is not opening the second page

Code for the second page

import {session} from 'wix-storage';
$w.onReady(function () {
 let subject = session.getItem("key1");
 console.log(subject);
 if (subject === "Beats") {
     $w("#dropdown1").selectedIndex = 0;
     //$w("#myElement").placeholder="Enter your name";     (code to change placeholder)
 }
});

Thank you for your help and sorry to bother you with the extra questions

@itsdjkcofficial The link property of the Button needs to be set before clicking the button:

import {session} from 'wix-storage';

$w.onReady(function () {
    $w("#button2").link = "/contact";
});

export function button2_click(event) {
    session.setItem("key1", "Beats");
    console.log("success");
}

@yisrael-wix Hi, I am facing the same problem here.

My first page is using normal Text column to try to link to a page where the info can be readily displayed on the selected dropdown on target page.

My first page Text is #text11 and target page dropdown is #dropdown1 with value All, Men, Women. It is a fashion page for user to click #text11 on first page and direct them to the info displayed by the selected dropdown page (for eg: all women clothing on target page once they click Shop Women on first page)

import { session } from ‘wix-storage’ ;

$w . onReady ( function () {
$w ( “#text11” ). link = “/dropdown1” ;
});

export function dropdown1_click ( event ) {
session . setItem ( “dropdown1” , “women” );
console . log ( “success” );
}

On Target page

import {session} from ‘wix-storage’ ;

// …

let value = session.getItem( “text” ); //“women”

Sorry that I am very new to corvid and no idea how to run the code but keep trying now for the website.

Hope you may help :wink: Appreciate so much!