I want to create Charts at the end of this project and have some options you can choose for the chart you want to create. There is a dropdown list with a few options: what kind of chart you want to have and checkboxes for the data that is going to be in it. To my problem, I want to program an if else statement which gives me a feedback when the statement is true, it should show me an alert with "true" in it.
I already have a function that gets me the selected value of the list, but if I build up the if else statement I don't get the expected result. I´ll therefore show you the code:
<button id="button" onclick="function2()"><strong>create Chart</strong> </button>
<script>
function getSelectValue()
{
var selectedValue=document.getElementById("Grafikliste").value;
console.log(selectedValue)
}
getSelectValue();
if (selectedValue=="balkendiag")
{
button.onclick(alert("True"))
}
else {
alert("Error!!!")
}
}
and here you see the code for the list
<select id ="Grafikliste" onchange="getSelectValue()">
<option value="balkendiag">Balkendiagramm</option>