Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove inline styles

Status
Not open for further replies.

Floyd7

Programmer
May 23, 2007
35
US
Hi,

I know nothing about javascript, so please be kind. I am trying to remove inline styles from data output. I use SQL Server & Coldfusion. The messed up output is coming from a query. The query is named "getinfo" and the field is named "content". I tried the following code, but it doesn't seem to be working. Any advice (dumbed down, please) would be much appreciated.

<cfoutput>
<script language = "javascript">

var before = "#getinfo.content# <p>stuff</p> with <br>tags</br>";
var after = #getinfo.content#.replace(/<[^>]*>/g, "");
alert(after);// some stuff with tags
</script>
</cfoutput>
 
[0] >var before = "#getinfo.content# <p>stuff</p> with <br>tags</br>";
This isn't really exactly right. br should be empty tag. If you want line break, you can do this.
[tt] var before = "#getinfo.content# <p>stuff</p> with <br />tags"; [/tt]
or continue to use p tag.
[tt] var before = "#getinfo.content# <p>stuff</p> with <p>tags</p>";[/tt]

[1] >var after = #getinfo.content#.replace(/<[^>]*>/g, "");
If you really want client-side js on this, you can do this.
[tt] var after = "#getinfo.content#".replace(/<[^>]*>/g, ""); [/tt]

[1.1] But I would say you can also do it server-side with rereplace?
[tt] var after = '#rereplace(getinfo.content,"<[^>]*>","","All")#'; [/tt]
 
This:
Code:
var after = #getinfo.content#.replace(/<[^>]*>/g, "");
should be
Code:
var after = before.replace(/<[^>]*>/g, "");

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top