Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    textarea with html in it

    Hi,

    I'm having quite a big problem. On my page, i have a textarea that is part of a form.
    In that textarea, the html code that is submitted from the previous page is shown.
    The problem is that because of all the html tags in it, it breaks the normal html structure by also interpreting the html that's inside the text area.

    How can i make sure it doesn't do that?

    I'll give you an example to explain better:

    Code:
    <form ....>
              <textarea name="htmlfromthepreviouspage">HTML COMES HERE AUTOMATICLY AND INCLUDES </textarea>. This makes the textarea close while this is not what i want it to do! How can I prevent this from happening? Or to say it otherwise: how can i make the text/html in the textarea to not be interpreted. The html that has to be inside this textarea is send together with the source of the page as i use a php echo</textarea>
    I'm sorry it's so vague but it's difficult to explain for me.
    If you have questions, just ask! Thank you for your time!

  • #2
    Regular Coder
    Join Date
    Aug 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's the part of the code that i'm talking about:

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    function submitForm() {
    	//make sure hidden and iframe values are in sync for all rtes before submitting form
    	updateRTEs();
    
    	//change the following line to true to submit form
    	rte1 = htmlDecode(document.RTEDemo.rte1.value);
    	document.write('<b><u>Gegevens controleren</u></b>');
    
    	document.write('<form action="http://www.webmasterhelp.biz/beheer/putindb.php?chpage=<?php echo"$page";?>" method="POST">');
    
    	document.write('<br>Wijzigende pagina: <?php echo"$page";?>');
    	document.write('<br> HTML code:<br><textarea rows="30" cols="50" name="htmlcode">');
    	document.write(rte1);
    	document.write('</textarea>');
    	document.write('<p><input type="submit" name="submit" value="Opslaan" /></p>');
    	document.write('</form>');
    
    
    
    }......
    With rte1 being the variable that contains html

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or is there a php function that can temporarly 'escape' the html?

  • #4
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by arne2 View Post
    or is there a php function that can temporarly 'escape' the html?
    yes there is:
    htmlentities()

    and it's counter part:
    html_entity_decode()

  • #5
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    what about htmlspecialchars()?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •