SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    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>
    I cant see it ...

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    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

  3. #3
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dc dalton
    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
    This is correct. IE hates this and makes your attempt switching to standard compliance mode all in vain. IE will be i quirks mode. Nevertheless it is good practice to have the prolog in all XML documents and XHTML is by definition XML. You should implement content type negotiation server-side to support different rendering for different clients.
    Quote Originally Posted by dc dalton
    2. Why do you have your javascript in the body? Either put it in a script block in the head or external js file
    Totaly agree with you here dc dalton.
    Quote Originally Posted by dc dalton
    3. You dont need this //[[CDATA[ OR this: //]>>


    In xhtml 1.0 strict ....... get them out

    thats all I see just glancing
    As a matter affect. There are times you need to use [[CDATA[ but the corrent syntax is:
    Code:
    <![CDATA[
    // JavaScript goes here
    ]]>
    When serving XHTML as application/xhtml+xml ordinary HTML (and XML) comments like <!-- comment --> are (and should be) ignored by the XML/XHTML parser. That is: They do not exist. Itīs like writing nothing. This JavaScript code does not exist and canīt be interpreted by the JavaScript engine as the HTML-parser does not forward it. There is a lot of debate in how you exactly should write to both support legacy and future browsers but that you have to google about and get your own opinion.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •