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 3 of 3

Thread: Croping a VAR

  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Bounemouth (UK)
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Croping a VAR

    Hi,

    I have programmed a var (contains postcode information) ,however I wish to crop it down so that I only get returned the value's before a " " has been entered e.g.

    If a value of "SO22 6NT" is entered I only want the SO22 in the var,

    I can do this in Basic using Instr but dont know how to do this in Javascript, can anyone point me in the correct direction,

    Thanks

    Nick Gibbons

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this will do it

    var str = "SO22 6NT"
    str = str.substring(0, str.indexOf(" "));

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Bounemouth (UK)
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    That worked a treat thanks!


  •  

    Posting Permissions

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