concatenating-text-input-with-link

I basicly need the solution on the follwing page but translated into a wix code. THX!

The customer should be able to type in his id number to access a custome web page.

See the article Wix Code Tutorial: Creating Custom Member Profile Pages .

Hello

  • Add a user input element to allow the user to input his id number.

  • Take the input value :

let id = $w('#input1').value
  • Get the link you want and add the id to it:
 let Link =  'http://translate.google.com/#en/nl/' + id
  • Use wix location to link to it:
wixLocation.to(Link)

Good Luck
Massa

Hello Massa,
thanks a lot.

I created an imput element ( #searchtext) can you explain me the next steps little bit more detailed.

Thank you and best regards,
Mola

@Mola Beogo

First you have to decide How would you want to get the user input value (on button click, on input key change, on input change…). To make it easier to explain i will assume there a button

Here’s the steps you need to follow:

  • Add onclick event to the button (properties panel → onClick)

  • In the code section inside the onclick function you get the input value.

  • You link to it.

Here’s a code snippet to help you understand how it would look like:

export function button1_click(event, $w) {
 //Add your code for this event here: 
 let id = $w('#searchtext').value
 let Link = '/What ever the link is/' + id
 wixLocation.to(Link)

}

*note that the properties panel of each element shows the event that can be added to that element

Best
Massa

Hello Massa,

i have an error on this part

wixLocation.to(“/dashboard”)

what could be the problem?

I mean wixLocation.to (Link)…

Problem solves! i forgot to put import wixLocation from “wix-location” on the top.

Thank you very much Massa! Your are the best!