SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: What is wrong with this?
-
Apr 7, 2005, 18:28 #1
- Join Date
- Mar 2005
- Posts
- 18
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What is 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>
-
Apr 7, 2005, 18:51 #2
- Join Date
- Nov 2004
- Location
- Right behind you, watching, always watching.
- Posts
- 5,431
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Not sure what the problem is (since you didnt say) BUT three things I see right off the bat:
1. Get rid of this: <?xml version="1.0" encoding="UTF-8"?>
IE Hates that tag and it will make your life miserable
2. Why do you have your javascript in the body? Either put it in a script block in the head or external js file
3. You dont need this //[[CDATA[ OR this: //]>>
In xhtml 1.0 strict ....... get them out
thats all I see just glancing
-
Apr 7, 2005, 23:53 #3
- Join Date
- Nov 2003
- Location
- Malmoe, Sweden
- Posts
- 265
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by dc dalton
Originally Posted by dc dalton
Originally Posted by dc dalton
Code:<![CDATA[ // JavaScript goes here ]]>
Bookmarks