Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why script does not work...

    this works:

    if (parts[3] == "#742") {
    tiny.image = hot;
    } else {
    tiny.image = cold;
    }

    but this dont, why:

    if (parts[3].CharAt(0) == "#") {
    tiny.image = hot;
    } else {
    tiny.image = cold;
    }

    I need to get firts character of parts[3] and if it is # then go on...
    parts[3] can be "#xxx", "$xxx", "ABCD" or "1234"


    Am I stupid or what?

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by oh5yw View Post
    this works:

    if (parts[3] == "#742") {
    tiny.image = hot;
    } else {
    tiny.image = cold;
    }

    but this dont, why:

    if (parts[3].CharAt(0) == "#") {
    tiny.image = hot;
    } else {
    tiny.image = cold;
    }

    I need to get firts character of parts[3] and if it is # then go on...
    parts[3] can be "#xxx", "$xxx", "ABCD" or "1234"

    Am I stupid or what?
    If you're going to play with JavaScript -> RTFConsole, that's why it's there.

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what is rtfconsole?

  • #4
    New Coder
    Join Date
    Jan 2004
    Location
    London, England
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts
    May I also suggest that you post a complete working page, with just your error in it? What you've posted requires some work before it can be run.

    One problem is that CharAt should be charAt.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by Arty Effem View Post
    If you're going to play with JavaScript -> RTFConsole, that's why it's there.
    This response was wholly uncalled for. If you don't want to help a newcomer, then I suggest that you keep quiet.


    1 Posting rules

    1.1) Always be respectful and polite when posting- There is absolutely no excuse to be rude, confrontational, or hostile when posting on CodingForums.com. This is a place where web programmers come together to solve problems, not create them. Flaming can get you banned.


  •  

    Posting Permissions

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