Forum Moderators: open
//displays an alert box with a php varible $msg passed into it
function echoAlert($msg){
echo "alert('$msg')";
}//echoAlert
$var = ("File Written to Sybase01\\\insurance$\\\MSBCBS\\\Send Log\\\Sending\\nContents:");
//$lines is an array of a multiple line text file
foreach($lines as $i){
//function to be used later
//writeLog($username, $i);
$var .=("\\n {$i}");
}//foreach
echoAlert($var);
This code is executed by another javascript file when the user clicks a button. The problem is my alert box says error missing ")" after argument list. If I manually store multiple lines of var i.e.
$var .= ("\\n {$text1}");
$var .= ("\\n {$text2}");
The alert box works fine.
As I am not a Javascript person, I believe it either has something to do with the way the variable is stored in the array or my escape characters. Any suggestions, thanks in advance.
<script type="text/javascript">
function echoAlert(msg){
alert(msg);
}
</script>
<?php
$var = ("File Written to Sybase01\\\insurance$\\\MSBCBS\\\Send Log\\\Sending\\nContents:");
foreach($lines as $i){
$var .=("\\n {$i}");
}
?>
<script type="text/javascript">
echoAlert('<?php echo $var?>');
</script>