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.
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.