I am working on a simple dropdown menu
<select name="dog-names" id="dog-names">
<option value="rigatoni">Rigatoni</option>
<option value="dave">Dave</option>
</select>
My goal is to execute different JavaScript functions based on the option selected. For instance, I want to display an alert saying "Hello world" when Rigatoni is chosen and show "I love you" when Dave is picked.
function Hello() {
alert("Hello world");
}
function Love() {
alert("I love you");
}
I understand that I could pass the selected value as a parameter to a function and use if/else statements, but I am looking for a way to achieve this without using conditional statements in my code.
Is there any solution for this?