Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you absolutely have to keep the popup function as is, I found a solution with help from <a href="https://stackoverflow.com/questions/97578/how-do-i-escape-a-string-inside-javascript-inside-an-onclick-handler/97804#97804">this answer</a> to "<a href="https://stackoverflow.com/questions/97578/how-do-i-escape-a-string-inside-javascript-inside-an-onclick-handler">How do I escape a string inside javascript inside an onClick handler?</a>".</p> <pre><code>&lt;?php $blah = "&lt;h1&gt;Well&lt;/h1&gt;"; $test = "&lt;h2&gt;Done&lt;/h2&gt;"; echo '&lt;script type="text/javascript" src="fetchlayers.js"&gt;&lt;/script&gt;'; $formcode = '&lt;form action="process.php" method="post" enctype="multipart/form-data "&gt; &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="file" id="file"/&gt; &lt;br /&gt; &lt;input type="submit" name="submit" value="Submit" onclick="setTimeout(function() { sendInfo(\\x27'.$blah.'\\x27, \\x27'.$test.'\\x27); }, 1250);" /&gt; &lt;/form&gt;'; echo "&lt;h1&gt;hello&lt;/h1&gt; &lt;div id='form'&gt; &lt;a href='#' onclick='popup(\"" . addslashes(str_replace("\n", ' ', $formcode)) . "\"); return false;'&gt; click here&lt;/a&gt; &lt;/div&gt;"; ?&gt; </code></pre> <hr> <p>Before edit:</p> <p>Maybe you can do it differently.</p> <p>Javascript functions:</p> <pre><code>function popup(id, params){ var html = document.getElementById(id).innerHTML; if (params != undefined) { html = findAndReplaceStrings(html, params); } var child1 = window.open ("about:blank"); child1.document.write(html); child1.document.close(); } function findAndReplaceStrings(text, json) { for (var x in json) { text = text.replace(x, json[x]); } return text; } </code></pre> <p>HTML hidden code:</p> <pre><code>&lt;div style="display:none;" id="process"&gt; &lt;form action="process.php" method="post" enctype="multipart/form-data "&gt; &lt;label for="file"&gt;Filename:&lt;/label&gt; &lt;input type="file" name="file" id="file"/&gt; &lt;br /&gt; &lt;input id="submit" type="submit" name="submit" value="Submit" onclick="setTimeout(function() { sendInfo('{param1}', '{param2}'); } ), 1250);" /&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>HTML link with json:</p> <pre><code>&lt;a href="#" onclick="popup('process', {'{param1}':'&lt;h1&gt;Well&lt;/h1&gt;', '{param2}':'&lt;h2&gt;Done&lt;/h2&gt;'}); return false;"&gt; click here&lt;/a&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload