www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: help with code

Hybrid View

  1. #1
    Join Date
    Apr 2012
    Posts
    13

    help with code

    hi im a beginner and im following this tutorial on you tube:
    http://www.youtube.com/watch?v=yQaAGmHNn9s

    i am also using notepadd++

    but when i copy the code and try to run it in my ie browser using the run>launch in ie funtion it doesnt write hey now brown cow its just blank so i click the error at the bottom right if the browser and it says syntax error this is it:
    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; BTRS130847; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; SRS_IT_E8790775B0765A5132A199; .NET4.0E; InfoPath.3)
    Timestamp: Thu, 26 Apr 2012 12:16:23 UTC


    Message: Syntax error
    Line: 8
    Char: 1
    Code: 0
    URI: file:///C:/Users/User/Desktop/amjad/new%20%202.html

    even if i delete everything from the notepad and run it i still get the same error
    this is my code if it helps:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html>
    <head>
    </head>
    <body>

    <script type="text/javascript">
    document.write("hey now brown cow");
    </script>

    </body>
    </html>

  2. #2
    Join Date
    Nov 2007
    Posts
    412
    This code works fine in IE8 and FF12.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html>
    <head>
    </head>
    <body>
    
    <script type="text/javascript">
    document.write("hey now brown cow");
    </script>
    
    </body>
    </html>

  3. #3
    Join Date
    Apr 2012
    Posts
    13
    i forgot i had to save it

  4. #4
    Join Date
    Apr 2012
    Posts
    13
    i have anouther problem i can get a pop up on screen but when i try to put an if block in it doesnt work

    what i want the program to do is check is the number is below 1 and higher than 99999 if it is not between 1-99999 it should pop up with a warning this is my code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <head>
    </head>
    <body>

    <script type='text/javascript'>

    var RunnerID = 999999
    var top = 99999
    var bottom = 1


    if ( (RunnerID<"bottom") && (RunnerID>"top") ){
    alert ("enter a number between 1-99999");

    function funky(){
    alert(ouch!!!);

    }

    funky();



    </script>
    </body>
    </html>

  5. #5
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    Code:
    (RunnerID<"bottom") && (RunnerID>"top")
    no quotes needed and without the closing bracket this will not work
    Last edited by Padonak; 04-26-2012 at 12:57 PM.
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  6. #6
    Join Date
    Jan 2011
    Posts
    117
    Quote Originally Posted by Padonak View Post
    (RunnerID<"bottom") && (RunnerID>"top")

    no quotes needed
    The puzzle is: "why did he quote them in the first place?"!

  7. #7
    Join Date
    Apr 2012
    Posts
    13
    Quote Originally Posted by Padonak View Post
    Code:
    (RunnerID<"bottom") && (RunnerID>"top")
    no quotes needed and without the closing bracket this will not work
    it does have a closing bracket its after the alert

  8. #8
    Join Date
    Jan 2011
    Posts
    117
    Quote Originally Posted by stevenn21 View Post
    it does have a closing bracket its after the alert
    and what about the:
    alert(ouch!!!);
    -why did you omit quotes here?!

  9. #9
    Join Date
    Apr 2012
    Posts
    13
    Quote Originally Posted by Troy III View Post
    and what about the:
    alert(ouch!!!);
    -why did you omit quotes here?!
    yep works now thanks guys but thats only a small fix this program is drilling me into the ground!

  10. #10
    Join Date
    Apr 2012
    Posts
    13
    now how can i get user input and if the value is outside 1-99999 pop up saying "invalid enter num between 1-99999"?

    please view this in your browsers:

    <!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"/>
    <title>enter you number</title>
    <script type='text/javascript'>

    function formValidator(){

    var RunnerID = document.getElementById('RunnerID');
    var EventID = document.getElementById('EventID');
    var top = 99999
    var bottom = 1


    if ( (RunnerID<bottom) && (RunnerID>top) ){
    function funky(){
    alert("ouch!!!");

    }



    funky();







    </script>
    </head>
    <body>
    <hr/>
    <h1>enter your number</h1>
    <hr/>
    Note: all fields are mandatory.
    <p/>
    <form>
    enter number between 1-99999: <input type="text" name="firstname"

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




    what i want to do is get the error if the number is not between 1-99999
    Last edited by stevenn21; 04-26-2012 at 01:47 PM.

  11. #11
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    lol
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  12. #12
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    you better count brackets first
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  13. #13
    Join Date
    Apr 2012
    Posts
    13
    Quote Originally Posted by Padonak View Post
    you better count brackets first
    do you mean here:
    if ( (RunnerID<bottom) && (RunnerID>top) ){
    function funky(){
    alert("ouch!!!");

    }

    ?

  14. #14
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    1 every opening bracket must have it's closing pair. you have 3 opening brackets and how many closing ones?
    2 every html-tag must have < and >
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  15. #15
    Join Date
    Apr 2012
    Posts
    13
    is this better?

    <!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"/>
    <title>enter you number</title>
    <script type='text/javascript'>

    function formValidator(){

    var RunnerID = document.getElementById('RunnerID');
    var EventID = document.getElementById('EventID');
    var top = 99999
    var bottom = 1
    }
    }

    if ( (RunnerID<bottom) && (RunnerID>top) ){
    }
    }
    function funky(){
    alert("ouch!!!");

    }
    }


    funky();







    </script>
    </head>
    <body>
    <hr/>
    <h1>enter your number</h1>
    <hr/>
    Note: all fields are mandatory.
    <p/>
    <form>
    enter number between 1-99999: <input type="text" name="firstname"/><br />

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles