SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    remove inline styles

    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>

    Thank you!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Assuming that #getinfo.content# becomes <p>stuff</p> with <br>tags</br>

    The following example works

    Code javascript:
    var before = "<p>stuff</p> with <br>tags</br>";
    var after = before.replace(/<[^>]*>/g, "");
    alert(after);

    So the following should work with CF

    Code javascript:
    var content = "#getinfo.content#";
    content = content.replace(/<[^>]*>/g, "");
    alert(content);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do I need to add anything special when I output #getinfo.content# in CF? It just doesn't seem to be working. When I look at the source code, I can see that the javascript is fnding #getinfo.content#, but CF is still outputting it with all the inline styles.

    Thanks for your patience!

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Not much is known about cold fusion here on the javascript forums. You'll want to check out the Cold Fusion forum instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Feb 2008
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Thank you for all your help. I did find a solution.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •