Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts

    Question Strange unterminated string literal error

    I can't find anything wrong with this code
    Code:
     <!-- Initialise the editor --><script>
    initRTE('<table align=\"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"> 
    <tbody>
    <tr></tr></tbody></table>', 'example.css'); 
    </script>
    However this throws an error in firebug and the page doesn't display it correctly, i get an error in firebug

    Code:
    unterminated string literal
    initRTE('<table align=\"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" widt...
    Does anyone have and idea whats going on?


  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    You don't need to escape "s inside a '-delimited string
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #3
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    thanks but i changed it to

    Code:
    <!-- Initialise the editor -->22<script>
    23initRTE('<table>
    24<tr></tr></table>', 'example.css');
    25</script>
    and I still get the error. however if i remove the <tr></tr> i get no error


  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    I agree with gjay's comment, but:-

    Have you tried escaping the /s?

    <tr><\/tr><\/tbody><\/table>', 'example.css');

    and keeping it all on one line?

  • #5
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by nikos101 View Post
    this throws an error in firebug and the page doesn't display it correctly, i get an error in firebug

    Code:
    unterminated string literal
    initRTE('<table align=\"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" widt...
    Does anyone have and idea whats going on?
    To break a single string over multiple lines, each segment must end with a '\'
    Code:
    '<table align=\"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"\ width=\"100%\">\ 
    <tbody>\
    <tr></tr></tbody></table>'

  • #6
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    The real trouble stems from the fact that I'm using a Rich text editor

    FreeRichTextEditor.com

    to generate the tables. It works fine when it is retrived from the database into the content page but when I try and display the html used in the editor for editing is when I get the problems


  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    In that case the solution is obvious!

  • #8
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    I agree, email the original coder


  • #9
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    Quote Originally Posted by nikos101 View Post
    thanks but i changed it to

    Code:
    <!-- Initialise the editor -->22<script>
    initRTE('<table>
    <tr></tr></table>', 'example.css');
    </script>
    and I still get the error. however if i remove the <tr></tr> i get no error
    the argument does


  • #10
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    ok so how would I automate the adding of \ to the argument to initRTE. eg how would I

    write code to convert

    Code:
    <table align="" border="4" cellpadding="0" cellspacing="0" width="100&#37;">
    <tbody>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td></tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td></tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td></tr></tbody></table>
    into

    Code:
    <table align="" border="4" cellpadding="0" cellspacing="0" width="100%">\
    <tbody>\
    <tr>\
    <td>&nbsp;</td>\
    <td>&nbsp;</td>\
    <td>&nbsp;</td></tr>\
    <tr>\
    <td>&nbsp;</td>\
    <td>&nbsp;</td>\
    <td>&nbsp;</td></tr>\
    <tr>\
    <td>&nbsp;</td>\
    <td>&nbsp;</td>\
    <td>&nbsp;</td></tr></tbody></table>


  • #11
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Use a text editor using find and replace.

  • #12
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    yes but I want it done dynamically with Javascript so that the user doesn't need to do find and replace


  • #13
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,906
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Arrh, to be sure, you can't be doing it as the Javascript has to be a valid string before you manipulate it to turn it into a valid string .....

    "If I were you, I wouldn't start from here" as the Irishman said when asked the way to Dingle.

  • #14
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    Man that kind of stinks a bit.

    How on earth am I going to pass the content data to the rich text editor for editing. Maybe I could do it with php?


  • #15
    Regular Coder
    Join Date
    Jun 2007
    Location
    USA
    Posts
    527
    Thanks
    26
    Thanked 74 Times in 72 Posts
    You need to put the sting all on one line.
    Trinithis


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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