pmcmicha
Technical User
- May 25, 2000
- 353
I am attempting to remove spaces and other special characters from a variable reference. This reference is passed from an array. This array is based into a function to build a table. That part works without a problem, but I would like to be able to create an <a href="" without the real variable name, but with one that does not have the spaces or other special characters.
Here is what I came up with, but it goes into an infinite loop.
(If you cannot have a space between the '+' sign and whatnot, in my code there is not a space, but to get this to appear in a more readable format, I added a space.)
While this looks right, I know that I am missing something from this idea. I am also quite new to this language and any help is appreciated.
Thanks in advance.
Here is what I came up with, but it goes into an infinite loop.
Code:
var name = this.data[i*this.columns+j];
while(name.indexOf(" ") != -1) {
var n_name = name.substring(0,name.indexOf(" ")) + name.substring(name.indexOf(" ")+1,name.length);
}
doc.write("<td><a href=\""+n_name+"\">");
...
While this looks right, I know that I am missing something from this idea. I am also quite new to this language and any help is appreciated.
Thanks in advance.