Feedback on: Creating 'Encoded' Name & Value Pairs, January 20, 2002 at 04:08:52:
You are here: irt.org | About | Feedback | 3505 [ previous next ]
Feedback on:
Creating 'Encoded' Name & Value Pairs
Sent by
John McGuire on January 20, 2002 at 04:08:52:
Worth:
Very worth reading
Comments:
I thought you might like this bit of coding for the users that needed to decode spaces as + and can't use the hex equivelent.
function dcode(string) {
string = unescape(string);
string = replace(string,"+"," ");
return string;
}
function replace(string,text,by) {
// Replaces text with by in string
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return string;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return string;
if (i == -1) return string;
var newstr = string.substring(0,i) + by;
if (i+txtLength < strLength)
newstr += replace(string.substring(i+txtLength,strLength),text,by);
return newstr;
}
I hope this is useful. The replace can be used for other things as well. Please let me know if this coes in hand.
John McGuire
BlackLight Systems Design
Other feedback on 'Creating 'Encoded' Name & Value Pairs' - show all
- Creating 'Encoded' Name & Value Pairs - vd May 08, 2007 at 13:01:40
- Creating 'Encoded' Name & Value Pairs - Vrushali October 08, 2002 at 02:54:24
- Creating 'Encoded' Name & Value Pairs - John McGuire January 20, 2002 at 04:08:52
- Creating 'Encoded' Name & Value Pairs - Chalon Clemons October 17, 2001 at 14:17:16
- Creating 'Encoded' Name & Value Pairs - JackFunkMasterFunkJack April 03, 2001 at 08:40:20
- Creating 'Encoded' Name & Value Pairs - Mark McVicker January 14, 2001 at 17:10:59
- Creating 'Encoded' Name & Value Pairs - patel manisha July 12, 2000 at 15:24:33
- Creating 'Encoded' Name & Value Pairs - Warren Ward April 24, 2000 at 15:11:59
- Creating 'Encoded' Name & Value Pairs - Vincent January 12, 2000 at 17:56:50
- Creating 'Encoded' Name & Value Pairs - secURLinx September 22, 1999 at 00:19:24
- Creating 'Encoded' Name & Value Pairs - maurice mthombeni July 30, 1999 at 02:16:39
- Creating 'Encoded' Name & Value Pairs - Jak Kulas July 25, 1999 at 12:59:50
- Creating 'Encoded' Name & Value Pairs - JASON ROSEN April 20, 1999 at 19:37:58
- Creating 'Encoded' Name & Value Pairs - RL Crawford April 15, 1999 at 11:29:07
- Creating 'Encoded' Name & Value Pairs - Robert Watson April 15, 1999 at 09:36:20
- Creating 'Encoded' Name & Value Pairs - Marc Campforts April 15, 1999 at 03:05:41
- Creating 'Encoded' Name & Value Pairs - John Horne April 14, 1999 at 11:44:53
- Creating 'Encoded' Name & Value Pairs - Lasse Johansson April 14, 1999 at 09:58:40
- Creating 'Encoded' Name & Value Pairs - Don Ellis April 13, 1999 at 09:31:13
- Creating 'Encoded' Name & Value Pairs - Nick Chase April 09, 1999 at 16:32:16
©2018 Martin Webb