Jump to content

Previewing Textarea box


graham23s

Recommended Posts

Hi Guys,

 

i have coded a basic html textarea box where the user can input html formatting to send via mail() i was going to add a preview button to show it (html formatted etc) before sending, im wondering what would be the best way to do this?

 

any advice would be great!

 

cheers

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/129082-previewing-textarea-box/
Share on other sites

I think a quick and simple way to do this Graham would be to define a <div></div> using CSS with a fixed width and height, with overflow set to auto.  I would then hide this until the user has clicked on the preview button using something like:

 

if (isset($_POST['preview']))
{
   // show div 
   echo "<div class='textBoxPreview></div>";
}
else
{
   // do nothing
}

 

No all you need to do is add the preview form button to your form.  When the form is submitted, collect the data that is posted from the textbox and echo it into the div you defined.  The div will act as a sort of viewport where the user will see the html that they have input.

 

Hope that helps  :)

 

Rob

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.