Results 1 to 2 of 2

Thread: unterminated string literal in text area

  1. #1
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default unterminated string literal in text area

    Hi, im having a little trouble with this hope someone might be able to help me with it.

    well first of, i have two text area. one in the parent window the other is in the child window. what i am trying to do is that whenever i saved the values in the child window text area, it would populate in the parent window.

    this is the javascript which is called with php ($tmp_desc is a php variable), that i have implemented in the child window:-

    PHP Code:
    echo "<script defer>
    o = window.opener.getElement('case_newdeflens_FX_CASE_DESCRIPTION');
            if (o) o.value = '
    $tmp_desc'
            setTimeout('window.close()', 500);
    </script>"


    it seems that when i leave spaces in the text area i will hit the 'unterminated string lateral' error.


    Error: unterminated string literal
    Source File: http://192.1.7.3/NewCase/_case_descr...ensBM_f1462b72
    Line: 21, Column: 19
    Source Code:
    if (o) o.value = 'DHLDJFL;KFJS;LF<br />

    is there a workaround to this problem ? thanks
    Last edited by jscheuer1; 11-08-2010 at 11:55 AM. Reason: formatting

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Really more of a PHP than javascript question, instead of (more like what you must have):

    PHP Code:
    <?php
    //some preliminary stuff
    echo "<script defer> 
    o = window.opener.getElement('case_newdeflens_FX_CASE_DESCRIPTION'); 
            if (o) o.value = '
    $tmp_desc
            setTimeout('window.close()', 500); 
    </script>"
    ;
    //some later stuff perhaps
    ?>
    Try:

    PHP Code:
    <?php
    //some preliminary stuff
    ?>
    <script defer> 
    o = window.opener.getElement('case_newdeflens_FX_CASE_DESCRIPTION'); 
            if (o) o.value = '<?php echo $tmp_desc?>
            setTimeout('window.close()', 500); 
    </script>
    <?php
    //some later stuff perhaps
    ?>
    Spaces should be fine, but you're going to need to escape single quotes in the $tmp_desc variable.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •