Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Feedback on: Creating 'Encoded' Name & Value Pairs

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


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 21st December 2007. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.