6th Nov 2017, 3:32 PM
B.D
B.D - avatar
3 Respostas
+ 3
In Html, set <form name="form" onsubmit="sel(event)"> In Javascript, set function sel(e) { e.preventDefault(); var sela = document.getElementById("pet"); var text = sela.options[sela.selectedIndex].text; if(text !== '') { window.location.href= `https://www.google.com/search?q=${text}` } } Check out the solotion: https://code.sololearn.com/W3Dh91C746TS/?ref=app
11th Nov 2017, 1:47 PM
Calviղ
Calviղ - avatar
+ 4
var sel = document.getElementById("pet"); var text = sel.options[sel.selectedIndex].text; if(text !== '') { window.location.href= `https://www.google.com/search?q=${text}` } ^That should do it. I'm not sure sololearn will allow you to redirect to third party websites though.
6th Nov 2017, 3:49 PM
AgentSmith
+ 1
Thanks
11th Nov 2017, 2:51 PM
B.D
B.D - avatar