There is a very long select-box in my html document. Every option has got an own name. I want to convert the value-string of the selected option into a javascript-variable. Or do I have to do it with a switch-case-query? Example:
var basketball = "changeable-string";
var handball = 760;
var basketball = null;
var baseball = "description: ball-game to play";
function myFunction() {
//Now I want to work with the name of the variable
//I would use switch case, but longer select-boxes would take more code...
//What shall I do?
}
<select name="box" onchange="myFunction();">
<option value="football">Football</option>
<option value="handball">Handball</option>
<option value="basketball">Basketball</option>
<option value="baseball">Baseball</option>
</select>