Missing) after argument list in html form code

I am trying to use the following code to display $ formcode, which is the html code for a form, in popups. I understand that this is not an ideal method, but I want to understand why it does not work.

<?php
$blah = "Well"; $test = "Done";
echo '<script type="text/javascript" src="fetchlayers.js"></script>';
$formcode = "<form action=\"process.php\" method=\"post\" enctype=\"multipart/form-data \"><label for=\"file\">Filename:</label><input type=\"file\" name=\"file\" id=\"file\"/> <br /><input type=\"submit\" name=\"submit\" value=\"Submit\" onclick=\"setTimeout(function() { alert('$blah'); },1250);\" /></form>";


echo "<h1>hello</h1>
<div id='form'>
<a href='#' onclick=\"createpopup('" . htmlentities($formcode) . "'); return false;\">
click here</a>
</div>";

      

In Firebug, I get a missing) after the argument list, which seems somewhat arbitrary since there is a right number of parentheses.

0


a source to share


3 answers


I'm not sure if it is or not because I cannot test it, but check the warning ('$ blah')

it should be with \ "i think



alert(\'$blah\')

      

+2


a source


I'm not sure what you mean by not working, but if you mean the window is not showing up, the problem is in your fetchlayer.js file . But other wise ones let us know exactly what you mean by not working.



0


a source


The content of $ formcode must be double-escaped single quotes:

alert(\\'$blah\\');

      

so that the string contains "\".

0


a source







All Articles