First of all, is it even possible to write if/else statements directly in html with onclick attribute? And if so, why is my code not working?
So this is a button. The "Calc.Input.value" refers to a text input and I want to display an error message if that field is 0 or blank. In all other cases I want some other things to happen as you can see. This is not relevant though, as everything after the "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;';}">
onclickand perform the conditional expressions within the function?if ("Calc.Input.value == ''" || "Calc.Input.value == '0'")line is strange …document.write().