View Full Version : Croping a VAR

07-04-2002, 04:34 PM

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,


Nick Gibbons

07-04-2002, 05:01 PM
this will do it

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

07-04-2002, 05:08 PM
That worked a treat thanks!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum