Get Link Value From Object Literal, Onchange--javascript/html Select
I know how to operate this menu with a switch case routine, but I want to change my switch case to an object literal. Part A knows how to get the onchange value and open a window.
Solution 1:
This should make it dynamic.
functionvaluu() {
ddd = document.getElementById("sed").value;
window.open(foo(ddd), '_self');
}
You can do all this in one function like,
document.getElementById('sed').addEventListener ('change', function(e){
var lynk = {
'default': (''),
'next': ('nextly.html'),
'prev': ('previous.html'),
'gimme': ('http://patreon.com/bearly'),
'home': ('index.html')
};
window.open(lynk[e.target.value]);
});
Post a Comment for "Get Link Value From Object Literal, Onchange--javascript/html Select"