Really big problem with quotes
Introduction to problem (sorry for much text):
Be sure that HTML sintax is OK, I used PHP
highlighting and it recognized :o as smiley
and this was from javascript: openWindow
In PHP I'm constructing string that is one HTML table:
$table = "<table><tr height='20'><td>";
$table .= "<a href=javascript: openWindow('show.php?Id=4','show',760,600) class=someStyle>Link</a>";
$table .= "</td></tr></table>";
I'm using "FastTemplate" method of work (separating HTML and PHP) and
I assign value of "$table" var to template value "{TABLE}" like this:
$tpl->assign(TABLE,$table);
It is working and it inserts value of $table into HTML, which is
acctualy in part <script language="javascript">...</script>:
<html>
<body>
<script language="javascript">
var myTable="{TABLE}";
document.write(myTable);
</script>
</body>
</html>
Strange thing happened. When I'm executing page for the first
time (only then) I've got Javascript error because double
quotes are inserted automaticaly (very strange) along attributes
of <a href> tag like this:
<a href="javascript: openWindow('show.php?Id=4','show',760,600)" class="someStyle">Link</a>
So I got an error in my JavaScript because I have:
myTable = "<table><tr height='20'><td><a href="javascript: openWindow('sho....
so there is an error just at the begining of word "javascript:" because
of that double quote. After refresh of same page error and double quotes
disappears and it is just like it is constructed in "$table" PHP var.
Common example that will work for first page visit and always (but this is not
done with "FastTemplate" method):
<?php
$table = "<table><tr height='20'><td><a href=javascript: openWindow('show.php?Id=4','show',760,600) class=someStyle>Link</a></td></tr></table>";
?>
<html>
<body>
<script language="javascript">
var myTable = "<?php print $table;?>"
document.write(myTable);
</script>
</body>
</html>
I don't know why is problem appearing when loading page for the first time.
My Internet Explorer browser should write:
<a href=javascript: openWindow('show.php....
BUT NOT LIKE THIS (difference in double quote sign)!
<a href="javascript: openWindow('show.php....
After refresh it writes OK (without double quote sign)
<a href=javascript: openWindow('show.php....