SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help Me Before I Bang My Head On My Keyboard

    im trying to do this program for my cis 2800 class. i cant figure how to my function and the submit to link together. i understand the whole logic, but i cant get it to program. if x is checked than do this else window.alert..i need help pls..here's my code as of right now







    <?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>m5calhounCP5-4</title>

    <script type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS

    function checky()
    {
    if (document.form[0].elements[0].checked == true)

    window.alert("You must check the box if you agree to the terms!");


    else
    {
    window.alert("come on");

    }
    }


    function confirmsubmit()
    {

    if(document.form[0].checky




    }
    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </script>
    </head>
    <body>
    <form method = "post">
    <h1><center> User Agreement </center></h1>

    <h2> Terms <h2><hr/>
    <font face="Roman, Arial" size="3" color="blk"> <p>
    This website is provided for the use of its members. Others may view only those portions of the site accessible without having to sign in.<br/><p>

    The information posted by third parties on this site is for informational purposes and does not represent the views of "fincrime dot org"
    or the site administrators nor do we guarantee the accuracy of any posting.<br/><br/>

    As with any information you find on the internet the onus is on the reader to verify the information prior to acting on it.<br/><br/>
    This site is an independent entity that is provided by police officers for police officers as one more tool in the ongoing practice of their profession.<br/>
    </p></font>

    <hr/><h3> Agreement<h3/>

    <font face="Roman, Arial" size="3" color="blk">
    By indicating your agreement to the terms contained herein,
    you are acknowledging that you are entitled to be a member of this site.
    You are affirming that you are a police/law enforcement officer or security officer with a
    major corporation. False statements to such are illegal.</font>


    <p><input type = "checkbox" name ="checky" value = " I accept the terms and conditions." onclick = "checky()"/> <font size = "2"> &nbsp I Accept the Terms and Conditions.</font> </p>



    <p><input type = "submit" value = " Enter Site "/>


    </form>
    </body>
    </html>

  2. #2
    Non-Member
    Join Date
    Apr 2006
    Location
    Scotland
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Noone help him! I want to see if he bangs his head off the desk...












    But you could use this and NOT give yourself concusion:
    <input type="submit" onClick="checky()" value="Enter Site "/>

    I think you have to put "return true;" or "return false;" in the javascript if statement, but then again I have never even used JS so I dont know what Im talking about.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody who includes script text and uses <font> as an element in a document typed 'XHTML 1.0 Strict' ought to start banging their head now.

    Some rows are just too long to hoe.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Well the entire Javascript is included inside an HTML comment so if the page actually were served as XHTML then the entire Javascript is commented out and so wont run. The idea of placing Javascript inside a comment like that is to hide it from Netscape 1 and IE1 and 2 since Netscape 2 and IE3 which are also so old that no one uses them any more understand Javascript.

    You need to put a CDATA tag around the Javascript if you are inlining it in an XHTML page.

    With xhtml all tags and attributes are case sensitive. With a strict doctype you can't use deprecated elements such as font because you should be using stylesheet commands to do that.

    Try validating your page and fix all the errors and then maybe it will be closer to working. It is just about impossible to get a page to look and work the same in all major browsers if it has errors.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if (document.forms[0].elements[0].checked == true)
    Use this as your basic template:
    Code:
    <html>
    <head><title>some title</title>
    
    <script type="text/javascript">
    
    
    
    </script>
    
    </head>
    <body>
    
    </body>
    </html>
    If you add a DOCTYPE declaration, then you sort of have to know what you're doing. The way you have your page now, it will trigger what's called quirksmode rendering in browsers. Quirksmode rendering lets you write very sloppy html and the browser will display it. The basic template above will also trigger quirksmode rendering, so there is no difference.

  6. #6
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx..heres my final code...its works but its doesnt validate . now i need to fix my 20 errors

    <?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    " http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
    <html>
    <head>
    <title>m5calhounCP5-4</title>

    <script type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS

    function checky()
    {
    if (document.forms[0].*****.checked == true)

    window.open("http://www.worldofwarcraft.com/bc-splash.htm", "width = 200 height =200");
    else
    window.alert("You must check the box if you agree to the terms!");
    return false;

    }
    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </script>
    </head>
    <body>
    <form method= "post">
    <h1><center> User Agreement </center></h1>

    <h2> Terms <h2><hr/>

    <font face="Roman, Arial" size="3" color="blk"> <p>
    This website is provided for the use of its members. Others may view only those portions of the site accessible without having to sign in.<br/><p>

    The information posted by third parties on this site is for informational purposes and does not represent the views of "fincrime dot org"
    or the site administrators nor do we guarantee the accuracy of any posting.<br/><br/>

    As with any information you find on the internet the onus is on the reader to verify the information prior to acting on it.<br/><br/>
    This site is an independent entity that is provided by police officers for police officers as one more tool in the ongoing practice of their profession.<br/>
    </p></font>

    <hr/><h3> Agreement<h3/>

    <font face="Roman, Arial" size="3" >
    By indicating your agreement to the terms contained herein,
    you are acknowledging that you are entitled to be a member of this site.
    You are affirming that you are a police/law enforcement officer or security officer with a
    major corporation. False statements to such are illegal.</font>


    <p><input type = "checkbox" name = "*****" value = " I accept the terms and conditions."/> <font size = "2"> &nbsp I Accept the Terms and Conditions.</font> </p>



    <p><input type = "submit" value = " Enter Site " onclick = "checky();"/></p>

    </form>
    </body>
    </html>

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Try running it through the W3C validator and fix the errors.

    for example there is no such tag as <font>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Read felgall's short article here:

    http://javascript.about.com/library/blxhtml.htm

    and then start in on some basic css tutorials.


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
  •