When you delete all your tasks, you have a blank select, without options.
You need to protect your state in your addTaskfunction with
document.forms[0].tasks.options.length > 0
Something like that:
if (document.forms[0].tasks.options.length > 0 && document.forms[0].tasks.options[0].value == "tasks")
document.forms[0].tasks.options[0] = null;
See updated code
source
share