/    Sign up×
Community /Pin to ProfileBookmark

Whats wrong with this?

[code]<?xml version=”1.0″ encoding=”UTF-8″?>
<!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” xml:lang=”en” lang=”en”>
<head>
<title>Triangle Sum</title>
<style type=”text/css”>
p { margin-left:10px}
</style>
</head>
<body>
<form id=”triform”>
<fieldset>
<legend>Triangle Sum</legend>
<p>
<input type=”text” id=”one” name=”one” value=”Side One” /><br />
<input type=”text” id=”two” name=”two” value=”Side Two” /><br />
<input type=”text” id=”three” name=”three” value=”Side Three” /></p><br />
</fieldset><p>
<input type=”button” value=”Sum?” onclick=”TriangleCheck()”>
<input type=”reset” /></p>
</form>
<script type=”text/javascript”>
//[[CDATA[
function TriangleCheck(){
var sideone;
sideone = document.getElementById(“triform”).one.value;
var evalone;
evalone = eval(“sideone”);

var sidetwo;
sidetwo = document.getElementById(“triform”).two.value;
var evaltwo;
evalone = eval(“sidetwo”);

var sidethree;
sidethree = document.getElementById(“triform”).three.value;
var evalthree;
evalone = eval(“sidethree”);

if ((evalone + evaltwo < evalthree)||(evalone + evalthree < evaltwo)||(evalthree + evaltwo <

evalone)){
{
alert(‘The sum of the two sides is less than the third side’);
}
else
{
var sum;
sum = (evalone + evaltwo + evalthree);
alert(‘The sum of the triangle is ‘ + sum);
}
}
//]>>
</script>
</body>
</html>[/code]

I cant see it …

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 08.2005 — Too many brackets
evalone)){
{

Don't use [I]eval[/I] and reference the value directly.
var sideone = Number(document.getElementById("one").value);
Your page doesn't [URL=http://validator.w3.org/]validate[/URL]

I don't believe you understand the consequences of [URL=http://www.w3.org/MarkUp/2004/xhtml-faq]using xhtml[/URL]

Use html:&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Basic HTML&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;meta name="copyright" content="Basic HTML"&gt;
&lt;meta name="keywords" content="Basic HTML"&gt;
&lt;meta name="description" content="HTML template"&gt;

&lt;script type="text/javascript"&gt;
&lt;!--
// all JavaScript here

//--&gt;
&lt;/script&gt;

&lt;style type="text/css"&gt;
&lt;!--
/* cascading style sheet */

--&gt;
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;!-- html here --&gt;

&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @TheShadow 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.18,
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,
)...