theEclipse
Programmer
Does anybody know how to remove a new line character (\n) from a text string?<br><br>I tried using this:<br><br><i>//gets the html string from the div<br>var str=document.all.theTable.innerHTML;<br><br>//makes sure the loop runs once, and declare tempstr<br>var loop=true,tempstr='';<br><br>//the while loop<br>while (loop){<br><br>//if the string has an end of line character<br>if (str.indexOf('\n')!=-1){<br><br>//store everything before the eol into the tempstr variable<br>tempstr=str.substring(0,str.indexOf('\n'));<br><br>//add everything after the eol to the tempstr variable<br>tempstr+=str.substring(str.indexOf('\n')+1,str.length);<br><br>//write the tempstr to the string, so it can be checked<br>str=tempstr;<br><br>//if the string does not have an end of line character,<br>//don't run the loop again.<br><br>} else loop=false;<br>}<br></i><br><br><br>but for some reason that dosn't work, any ideas? <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.