Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-04-2002, 04:34 PM   PM User | #1
NICKGE1
New to the CF scene

 
Join Date: Jul 2002
Location: Bounemouth (UK)
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
NICKGE1 is an unknown quantity at this point
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
NICKGE1 is offline   Reply With Quote
Old 07-04-2002, 05:01 PM   PM User | #2
boywonder
Regular Coder

 
Join Date: Jun 2002
Location: New York, USA
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
boywonder is an unknown quantity at this point
this will do it

var str = "SO22 6NT"
str = str.substring(0, str.indexOf(" "));
boywonder is offline   Reply With Quote
Old 07-04-2002, 05:08 PM   PM User | #3
NICKGE1
New to the CF scene

 
Join Date: Jul 2002
Location: Bounemouth (UK)
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
NICKGE1 is an unknown quantity at this point
Thumbs up

That worked a treat thanks!
NICKGE1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:40 AM.


Advertisement
Log in to turn off these ads.