/    Sign up×
Community /Pin to ProfileBookmark

Error message

When I check the javascript code below on W3 I get this error and I need the < in my code. Any suggestions?

&#9993;
[COLOR=”Red”]
Line 48, Column 18: StartTag: invalid element name for (var i =0; i [COLOR=”red”]< [/COLOR]document.forms[0].tasks.length; ++i) {
&#9993;

Line 52, Column 18: StartTag: invalid element name for (var j =0; j [COLOR=”red”]< [/COLOR]document.forms[0].tasks.length; ++j) {[/COLOR]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta name=”generator” content=”HTML Tidy for Linux (vers 6 November 2007), see www.w3.org” />
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /><!– <meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″ /> –>
<title>To Do List</title>

<script type=”text/javascript”>
/* <![CDATA[ */
/* ]]> */
function addTask() {
if (document.forms[0].newtask.value == “”)
window.alert(“You must enter a value
in the New Task fi eld.”);
else {
if (document.forms[0].tasks
.options[0].value == “tasks”)
document.forms[0].tasks.options[0]
= null;
var newTask = new Option();
newTask.value = document.forms[0]
.newtask.value;
newTask.text = document.forms[0]
.newtask.value;
var numTasks = document.forms[0].tasks
.options.length;
document.forms[0].tasks.options[numTasks]
= newTask;
document.forms[0].newtask.value = “”;
}

function deleteTask() {
var selectedTask = 0;
var taskSelected = false;
while (selectedTask < document.forms[0].tasks.length) {
if (document.forms[0].tasks.options[selectedTask].selected== true) {
taskSelected = true;
break;
}
++selectedTask;
}
if (taskSelected == true)
document.forms[0].tasks
.options[selectedTask] = null;
else
window.alert(“You must select a task in
the list.”);
function ascendingSort() {
var newTasks = new Array();
for (var i =0; i < document.forms[0].tasks.length; ++i) {
newTasks[i] = document.forms[0].tasks.options[i].value;
}
newTasks.sort();
for (var j =0; j < document.forms[0].tasks.length; ++j) {
document.forms[0].tasks.options[j].value = newTasks[j];
document.forms[0].tasks.options[j].text= newTasks[j];
}

</script>
<style type=”text/css”>
/*<![CDATA[*/
select.c2 {width: 500px}
input.c1 {width: 150px}
/*]]>*/
</style>
</head>
<body>
<h1>To Do List</h1>
<form action=””>
<p>New Task <input type=”text” size=”68″ name=”newtask” /></p>
<p><input type=”button” value=”Add Task” onclick=”addTask()” class=”c1″ /> <input type=”button” value=”Delete Selected Task” onclick=”deleteTask()” class=”c1″ /><br />
<input type=”button” value=”Ascending Sort” onclick=”ascendingSort()” class=”c1″ /></p>
<p><select name=”tasks” size=”10″ class=”c2″>
<option value=”tasks”>Tasks</option>
</select></p>
</form>
</body>
</html>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PadonakJun 09.2012 — 1 fix wrong linebreaks

2 count brackets carefully
Copy linkTweet thisAlerts:
@webdev57authorJun 09.2012 — Ok, I can fix those items, so does that have a bearing on the fact that the validator is stating that the < is wrong? Thank you for your response that was very helpful.
Copy linkTweet thisAlerts:
@PadonakJun 09.2012 — another validator shows another error - they are programs and they can't think. the best validator is you <wink>
×

Success!

Help @webdev57 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...