Click to See Complete Forum and Search --> : ASCII Character Code


MarkSP
08-05-2003, 02:35 PM
I am trying to replace the TAB ASCII character code in a substring with a space. I cannot find the syntax. I can loop through a substring and find the TAB by using charCodeAt(0) == 9 but how do I replace the TAB with a space?

This code will loop through and replace var out (which I want to put the TAB ASCII code) and the var add which will be the space charCode.

Anyone know? VB Script is Char(9). What is the JS syntax?

function replaceChars(entry)
{
out = charCodeAt(9); // replace this
add = "P"; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1)
{
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
}
window.document.forms[0].FieldName_T.value = temp;
}

Any help will be greatly appreciated.

Khalid Ali
08-05-2003, 02:46 PM
you need to read this article....

http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/string.html#1194258

MarkSP
08-06-2003, 06:23 AM
Thanks allot Khalid Ali, This is the information I needed.