+ 2
Html forms
My problem is to make a form with two submit buttons. If you hit the first button, you will come to a website and if you hit the second button, you will come to an other website.
8 Respuestas
+ 1
first of all use onsubmit-function in a form
it looks like: <form onsubmit="a(event);">
then you change your function to:
function a(event){
event.preventDefault();
window.location.replace("https://www.google.com");
}
Then it should work.
You have to try this on your local machine because sololearn playground won't allow redirects
+ 2
Yeah but how link to a website in Js?
+ 2
Thanks
+ 2
Call function and make an if
Statement
+ 2
https://code.sololearn.com/Wbwfvdpa3gPa/?ref=app
The window.location.replace do not work here, do I have something wrong? 🤔
+ 1
call the same function and make an if statement in the function on which button was clicked
+ 1
window.location.replace(url)
+ 1
no problem. feel free to ask again