Hello,
Thanks for reading!
How can I create a button that will send user to custom link based on his imput on a placeholder?
For example, if he types 123 on the placeholder, when he clicks the button will be sent to www.google .com/123 ?
Thnaks all!
Just an simple example…
You have an INPUT-ELEMENT on your page, where you put in the subURL
$w.onReady(()=>{
$w('#myButtonID').onClick(()=>{
let mainURL = 'https://google';
let subURL = $w('#input1').value;
wixLocation.to(mainURL+subURL);
});
});
thanks so much!
what am i doing wrong?
*/
export function button66_click ( event ) {
[wixlocation](wixlocation.to("https://google.) [.](wixlocation.to("https://google.) [to](wixlocation.to("https://google.) [(](wixlocation.to("https://google.) ["https://google.](wixlocation.to(“https://google.) com/$w(‘#imput5’” );
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
}
would you log into my wix account and make it work for me? How much would you charge? I would give you my user name and pass. we can chat better via email.
Did you try → COPY and PASTE my CODE?
Your INPUT is —> imput5 <— or —> input5 <---- ?
No double-quotationmarks …
$w('#imput5 '" )
Either you use → + <—
let mainURL = STRING ---> 'https://www.google.';let subURL = STRING ---> 'com';
wixLocation.to(mainURL+subURL);
or a litteral…
let myURL = "google";
wixLocation.to(`https://www.${myURL}.com`);
And you better do not use → EXPORT-FUNCTIONS for button-control…
export function button66_click(event){...
Use the alternativ better coding way…
$w.onReady(()=>{$w('#button66').onClick(()=>{...CODE......CODE......CODE......CODE...});});
copy and paste does not work.
easier solution (verified works as of 7/21/2023)
just replace the url portion
import wixLocation from ‘wix-location’;
$w.onReady(function () {
const input1 = $w(‘#input1’);
const btn1 = $w(‘#button1’);
btn1.onClick(() => {
if (!input1.value) return;
wixLocation.to ( [https://google.com/${input1.value}
](https://google.com/${input1.value}`) ); }) });