Redirect to dynamic page

I have an input and I want to let the visitor to redirect him to a specific dynamic page when he/she type a code in the input

I’ll give you an example to understand :

I want this input :

To redirect to this dynamic page

According to the order code (EgAsM7#1) that is exist in this orders collection

and also I want this input to redirect to two or more than dynamic page (notice that in the three collections have the same column that called “Order Code”)

please I want just the code snippet for this

Eyad

I couldn’t understand what exactly you were trying to achieve. On one hand you said you’d like to redirect to a certain page, but on the other hand you wanted to redirect to “two or more than dynamic page”. What does it mean?
Please clarify.

Just I want to know how to redirect to a certain page

@eyadkhfarah

import wixLocation from 'wix-location';//at the top of the code page
//code.... inside an event handler:
wixLocation.to("/my-page-path");

I know where the (import wixLocation) I will but I didn’t understand the last one

@eyadkhfarah
Please take note of our Forum Guidelines , especially when you are telling us to just give you the code for this.

No Freebies.
Don’t expect anyone to provide code snippets or full solutions; the community is here to help you learn how to solve problems.

Search Before Posting.
Use the Forum search. There’s a great chance that someone has already solved the problem that you are facing. If you post a question that has already been asked and answered, your post may be locked. You might find the answer to your question by searching the Corvid documentation.

Search the forum for previous posts on linking to dynamic pages as there are many out there that you can use.
https://www.wix.com/corvid/forum/community-discussion/how-can-i-link-a-dropdown-user-input-element-to-a-dynamic-page
https://www.wix.com/corvid/forum/community-discussion/search-bar-redirects-to-dynamic-page-via-database-query

Thank you for your advice and I had saw this post however I followed this forum although it’s work but I still have an error 404

@eyadkhfarah Post your code

import wixLocation from ‘wix-location’;

export function searchButton1_click(event) {
wixLocation.to(‘/order-with-frame/${$w(“#iTitle”).value.replace(" “,”-“).replacce(“w”,”-")}’);
}

here @jonatandor35

For starters you have two c’s in the last replace.

  • why are you trying to replace the w ?
  • your replacement will only change the first appearance, if you have more than 1 space, you need to use different replacement.

What is the replacement of this value

Also you’re using instead of `

(for the wixLocation.to() string)

@eyadkhfarah try to explain what the desired replacement is.

What’s the difference please?

@eyadkhfarah See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

@jonatandor35 All right I have remove the w from the replacement and I had replace’ to ` in the wixLocation.to() but when I head to the preview I saw an error in the console say that the ( $w(…).value.replace(…).replace is not a function ) what is this mean and why this happen

@eyadkhfarah as GOS already mentioned, you wrote repla c ce instead of replace

Yes I got it :joy::joy: