How can I visit a selected link from drop-down list on external button in a new window?
HTML
<select id="atheist">
<option value="http://google.com">Google</option>
<option value="http://yahoo.com">Yahoo</option>
</select>
<input id="downloadbtn" type="button" value="download" />
JS
function openLink(){
var e = document.getElementById("atheist").value;
console.log(e);
var win = window.open(e, "_blank");
win.focus();
}
window.onload=function(){
var downloadbtn = document.getElementById("downloadbtn");
downloadbtn.onclick=openLink;
};
JS
function openLink(){
var e = document.getElementById("atheist").value;
var win = window.open(e, "_blank");
win.focus();
}
window.onload=function(){
var downloadbtn = document.getElementById("downloadbtn");
downloadbtn.addEventListener("click", openLink, false);
};
This is similar to the following: inputing text in textbox
I am supposing here you want select the site and want to open that site after click on downlad button.
HTML
<select id="select">
<option value="http://google.com">google</option>
<option value="http://yahoo.com">yahoo</option>
</select>
<button id="myButton">Download</button>
JS
var button = document.getElementById("myButton");
button.addEventListener("click", function() {
var select = document.getElementById('select');
var win = window.open(select.options[select.selectedIndex].value, "_blank");
win.focus();
},false);
DEMO