PDA

View Full Version : unterminated string literal in text area



awakener1986
11-08-2010, 10:46 AM
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:-


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_description.php?LeNs#LensBM_f1462b72
Line: 21, Column: 19
Source Code:
if (o) o.value = 'DHLDJFL;KFJS;LF<br />


is there a workaround to this problem ? thanks :confused:

jscheuer1
11-08-2010, 12:08 PM
Really more of a PHP than javascript question, instead of (more like what you must have):


<?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
//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.