0

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

<?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 missing ) after argument list which seems somewhat arbitrary, as the right number of parentheses is there.

1
  • It would be helpful to see the code this produces, which is what the browser sees. Commented May 7, 2009 at 2:24

3 Answers 3

2

I'm not sure if it's this or not, because I can't test it, but check the alert('$blah')

it should be with \' I think

alert(\'$blah\')
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

The content of $formcode needs to have the single quotes double-escaped:

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

so that the string contains "\'".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.