Note that there are some explanatory texts on larger screens.

plurals
  1. POQuoting quotation marks
    primarykey
    data
    text
    <p>Anyone got a way of thinking about this?</p> <p>I'm going a bit bats working on this:</p> <pre><code>$toReturn .= " function addProd(pExists) { document.getElementById('products').innerHTML = \"&lt;tr&gt;&lt;td id='prod_n'&gt;&lt;input type='text' size='10' maxlength='10' name='proj_n' id='prod_n' onchange=".chr(92).chr(34)."saveData(setSaveParams('ajaxSaveDataController.php', 'PROD', 'n'), this.value)".chr(92).chr(34)." value='"; $toReturn .="'&gt;&lt;/td&gt; &lt;td id='prod_spec'&gt; &lt;textarea cols='60' name='prod_spec' id='prod_spec' rows='20' onchange=".chr(92).chr(34)."saveData(setSaveParams('ajaxSaveDataController.php', 'PROD', 'prod_spec'), this.value)".chr(92).chr(34)." value='"; $toReturn .="'&gt;&lt;/td&gt;&lt;/tr&gt;\" + document.getElementById('prodsTab').innerHTML; if (pExists == 0) { document.getElementById('prodsTab').innerHTML = \"&lt;tr&gt;&lt;th id='proj_spec_h'&gt;Name&lt;/td&gt;&lt;th id='proj_spec_h'&gt;Spec&lt;/td&gt;&lt;/tr&gt;\" + document.getElementById('prodsTab').innerHTML;"; </code></pre> <p>I've transcribed that so don't worry overmuch about an off topic typo.</p> <p>What's going on here is I'm using PHP to write Javascript that calls an Ajax function, and what's blowing me away is the <code>"</code>s and the <code>'</code>s</p> <p>So I'm writing a return string, in PHP, so all that's in <code>"</code></p> <p>Then I want to write some innerHTML, so that I can put inside <code>\"</code></p> <p>Then the HTML arguments can be in <code>'</code></p> <p>All's fine so far.</p> <p>So then my onchange call is supposed to end up as <code>onchange="function('a', 'b')"</code>, well, where are my <code>"</code>s going to come from? If I use <code>"</code> that'll end the PHP string. If I use <code>\"</code> that'll end the innerHTML string. So I ended up getting PHP to interpret this <code>chr(92).chr(34)</code></p> <p>So that's very messy and it's starting to hurt my head.</p> <p>And now it's failing on that blank line after the second <code>$toReturn</code>, which I wanted there for readability.</p> <p>I must be doing something wrong in terms of style or, something.</p> <p>How do you handle nested <code>"</code>s?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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