Can anyone advise me what is wrong with the empty String check in the JavaScript below.
It works fine if I remove the line of code which checks for empty String, but I would like to display "Nothing selected" if the selection is empty.
<html>
<script language="JavaScript">
<!--
function update()
{
var selection = "";
var empty = "";
if (document.form1.TeaName.checked) selection += "Tea<br>";
if (document.form1.CoffeeName.checked) selection += "Coffee<br>";
if (document.form1.EggsName.checked) selection += "Eggs<br>";
if (document.form1.BaconName.checked) selection += "Bacon<br>";
if (selection.equals(empty)) selection = "Nothing selected.";
document.getElementById("currentSelection").innerHTML = selection;
}
-->
</script>
<body>
<form name="form1">
<div id="container" style="width:100%">
<div id="left" style="float:left; width: 30%;">
<h3>List 1</h3>
<input type="checkbox" onClick="update()" name="TeaName" value="Tea">Tea<br>
<input type="checkbox" onClick="update()" name="CoffeeName" value="Coffee">Coffee<br>
</div>
<div id="middle" style="float:left; width: 30%;">
<h3>List 2</h3>
<input type="checkbox" onClick="update()" name="EggsName" value="Eggs">Eggs<br>
<input type="checkbox" onClick="update()" name="BaconName" value="Bacon">Bacon<br>
</div>
<div id="right" style="float:left; width: 30%;">
<h3>Currently selected</h3>
<p id="currentSelection">Please make a selection.</p>
</div>
</div>
</form>
</body>
</html>
Thank you for your time,
James