Issue: Unable to jump and filter information on webpage based off the information from another webpage
Background/Intended behavior: I have 3 web pages: 1. Home Page 2. Law Page 3. Medical Page. Pages 2: Law & 3: Medical, have checkboxes that can filter a repeater of linked images on that page.
From the Home Page the user selects from two dropdown lists: Task and Location. Both task and location are required prior to clicking on a search button. When button is clicked, if the task == a Law task, then user will jump to the law page and the repeater will filter by the task selected and location. (Example: Task = fire fighter / Location = Dallas) Expected Result:
The same behavior would apply if a Medial task was selected instead of a Law task. (Example: Task = dentist / Location = Dallas) Expected Result:
Problem 1: I have searched a lot on Wix.com on how to code for a page to jump to another page based off the information entered. I desire to do an if statement checking the value of the task dropdown list, but I cannot find out how to jump to another page using javascript code in wix.
Problem 2: I also desire to carryover values from one page to be applied in another. Should I just have a global variables that by default is blank but can be altered between all three pages? Then upon load of pages 2 & 3 use that values for the variables to display the filters?
Thank you everyone for your assistance with finding a solution. It is a simple question, but becomes very complicated as it pertains to the Wix platform and using their API.
Solution 1: I used wix-location module to redirect user to another page. Relocation worked as desired.
Solution 2: I used wix-storage to store value across pages. Information was stored as desired, and recalled using the session.getItem().
[HOME PAGE]
import wixLocation from 'wix-location'; import {session} from 'wix-storage';
export function exploreSearchButton_click(event) {
if(($w('#categoryDropdown').value.length>0)&&($w('#stateLocationDropdown').value.length>0))
{
session.setItem("location",$w('#stateLocationDropdown').value);
switch($w('#categoryDropdown').value)
{
case "Doctor" :
session.setItem("category",0);
wixLocation.to("/medical-field");
break;
case "Dentist" :
session.setItem("category",1);
wixLocation.to("/medical-field");
break;
...
case "Police Officer":
session.setItem("category",0);
wixLocation.to("/civil-service-law");
break;
case "Fire Fighter":
session.setItem("category",1);
wixLocation.to("/civil-service-law");
break;
...
default:
console.log("Did not jump to another page.");
}
}
}
[MEDICAL PAGE]
import {session} from 'wix-storage';
$w.onReady(function () {
let newCategory = parseInt(session.getItem("category"));
if(newCategory>=0)
{
$w('#categoriesCheckboxGroup').selectedIndices = [newCategory];
$w('#stateLocationDropdown').value = session.getItem("location");
}
displayServicesInRepeater("medical-field");
Thank you all for your assistance.