Javascript: addContent - How to package

Using a sample for addContent (located at randomsnippets.com ) I came across a problem that I hope someone can help. It might not be the best / only way to fool this cat, but we have a PHP / MySQL page that needs to be modified for ADD strings for data entry when needed.

Their method works (write on their page), but the value for the FORM element TEXTAREA has its own form elements, including TEXTAREA. Closing the last TEXTAREA tag aborts the first value and issues the remaining code to the page without waiting for an insert with the Submit button. Sample results: Click here

The submit button successfully creates the part that is left inside, but you see the problem.


- Is there any way to use the javascript addContent function,

- enable the ADD button utility

- But don't use FORMS packaging?


Thanks for any help!

Brian

ps PHP is transparent. Directly including the HTML contained in the variable, because the TEXTAREA value gives the same result.

+1


source to share


1 answer


I don't really understand what you are trying to accomplish here, but it doesn't matter - the obvious problem is that you are including unescaped HTML in textarea

: the text textarea

must be escaped, just like you are avoiding text content elsewhere in the HTML document (conversion <

in &lt;

>

a &gt;

&

in &amp;

, etc.). The fact that you end up feeding the text back through the HTML browser doesn't matter - if you want the document to load properly, it must be escaped:

Example:

desired content such as this:



<tr>
   <td bgcolor="#F3F3F3" align="center" colspan="3"><hr size="1" color="#C0C0C0"></td>
</tr>

      

will be included in the textbox, for example:

<textarea>
&lt;tr&gt;
   &lt;td bgcolor="#F3F3F3" align="center" colspan="3"&gt;&lt;hr size="1" color="#C0C0C0"&gt;&lt;/td&gt;
&lt;/tr&gt;
</textarea>

      

+1


source







All Articles