You are not logged in.

#1 2022-10-18 14:17:30

firewalker
Member
From: Hellas (Greece).
Registered: 2006-06-05
Posts: 552

Really simple static html page

In an html list as the example bellow. Can I add a button to open the selected page? I know about the onchange event. I want to do it after pressing a button.

<!DOCTYPE html>
<html>
<body>

<h1>Select</h1>
<br>
<form>
<select name="Choose">
    <option value="https://.....">One</option>
    <option value="https://.....">Two</option>
  </select>
</form>
</body>
</html>

Γίνε ρεαλιστής, μείνε ονειροπόλος ...

Offline

#2 2022-10-18 15:48:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Really simple static html page

In the button handler:

var sel = document.getElementById('yourselectid');
var url = sel.options[sel.selectedIndex].value;
window.open(url);  // or: window.location = url;

Last edited by Trilby (2022-10-18 16:06:53)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-10-18 15:50:33

firewalker
Member
From: Hellas (Greece).
Registered: 2006-06-05
Posts: 552

Re: Really simple static html page

Thanks you!


Γίνε ρεαλιστής, μείνε ονειροπόλος ...

Offline

Board footer

Powered by FluxBB