Am I Missing a Step?

My goal is to link from a dynamic item page to a specific page on my site, based on an element value on the dynamic page.

On my dynamic page:

1. I’m trying to use a submit button’s event handler option, “onClick:”

2. Coding the function in the Developer’s Console:

export function submitbutton_click() {
//Add your code for this event here:

	var storeType = "/"+$w("#input9").value+"-grocery-list";  		// Declare var storeType to create needed URL 

            $w("#submitbutton").link = storeType;    // Set "SEE LIST" button to correct store list page URL 

}

(The variable “storeType” is derived from another element on the dynamic page which works out to be the needed (local) index page URL, “/Raleys-grocery-list”, for example.)

Challenge: After the submit button is pressed, it updates the Collection as necessary and the submitbutton’s link value is set to the proper URL, but it does not redirect. It just stays on the dynamic page.

I hope I explained that better! Any tips would be appreciated.

Hi,
When you use link , you basically assign the link to the button. If you wish to redirect to a different URL, you should use the Wix Location API instead:

import wixLocation from 'wix-location'; 


export function submitbutton_click() {
  //Add your code for this event here:
  var storeType = "/"+$w("#input9").value+"-grocery-list";// Declare var storeType to create needed URL
  wixLocation.to(${storeType});
}

Best,
Tal.

Hi Tal!

That solved it!

You taught me something new (new to me anyways). Because of your help, I also learned that the URL, in this case, is case sensitive.

Thank you very much!