How to give the links to selectbox options (dropdown list) | Sanwebcorner

How to give the links to selectbox options (dropdown list)

This very simple javascript tips to create a links to the select box(dropdown box) text. This is also very useful when create branches in websites you can use this type of select box with links. This type of concept is mostly used for responsive menu or mobile menu. 

The below example shows how to set the links to the select box options text. Just put the  onchange="location = this.value;" put this code into select tag and give the links in to the value section. The below image show how the textbox looks like. check the below demo page how it works.



Code for give links to the dropdown list or selectbox

<html>
<head>
<title>How to add links in select box</title>
<style>
select{
width:400px;
height:50px;
}
</style>
</head>
<body>
<h1>How to add links in select box</h1>
<select name="forma" onchange="location = this.value;">
<option value="http://www.sanwebcorner.com/2017/05/how-to-create-simple-drop-down-button.html">Dropdown Button</option>
<option value="http://www.sanwebcorner.com/2017/05/how-to-create-simple-404-error-page-and.html">404 Error Page</option>
<option value="http://www.sanwebcorner.com/2017/04/how-to-create-simple-mobile-toggle-menu.html">Mobile Toggle Menu</option>
<option value="http://www.sanwebcorner.com/2017/04/how-to-set-simple-overlay-effect-to.html">Simple Overlay Effect</option>
</select>
</body>
</html>