Firstly, is it even possible to write if / else statements directly in html with the onclick attribute? And if so, why is my code not working?
So this is the button. "Calc.Input.value" refers to text input, and I want to display an error message if this field is 0 or blank. In all other cases, I want some other things to happen, as you can see. This is not relevant, since everything after "else" worked fine before.
<INPUT TYPE="button" NAME="drop" id="dropbutton" style="background-color:#D1E8D5;" VALUE=" Släpp ankare " OnClick="if ("Calc.Input.value == ''" || "Calc.Input.value == '0'") {window.alert("Please enter a number");} else {document.getElementById('dropbutton').value=' Justera längd ';document.getElementById('length').innerHTML = Calc.Input.value;document.getElementById('dropbutton').style.cssText = 'background- color:#FFF6B3;';}">
source share