Error in Javascript string with new lines from php
Posted: 16 May 2017, 08:42
Hello! On page:
mluci.com/d/admin-index.php
- i tried to add database details from sql select into a div with javascript.
I have this php with js code:
but i get some javascript error in console and code don't work.
mluci.com/d/admin-index.php
- i tried to add database details from sql select into a div with javascript.
I have this php with js code:
Code: Select all
echo '<script type="text/javascript">
var theDiv = document.getElementById("detalii");
//Here we escape single quotes in php string, to have double-quotes inside string with single-quotes in JS
theDiv.innerHTML +=\'<div id="myModal'. str_replace('"', '\"', $row2['unic2']) .'" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">"'. str_replace('"', '\"', $row2['locatie2']) .'"</h4>
</div>
<div class="modal-body">
Proprietis:"'. str_replace('"', '\"', $row2['proprietati']) .'" <br/>
Problems:"'. str_replace('"', '\"', $row2['probleme']) .'"<br/>
Date:"'. str_replace('"', '\"', $row2['data']) .'"<br/>
Image:
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>\';
</script>';