# HTML and source codes display

**URL:** <https://forum.servoy.com/t/html-and-source-codes-display/13165>\
**Category:** Classic Servoy\
**Created:** [November 10, 2010, 6:59am UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165 "2010-11-10T06:59:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [November 10, 2010, 6:59am UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/1 "2010-11-10T06:59:17Z")

</div>

I am currently working on displaying HTML and it’s source code on the screen.

I’ve got 2 questions regarding this:

1. Is there a way of displaying HTML preview and HTML codes in 2 different types of text area?  
I tried using TEXT\_AREA to display the HTML source codes but HTML tags were not displayed.

2. When using HTML\_AREA to display HTML source codes, can I also embed images? If this is allowed, where should these images reside?

Thanks!

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 10, 2010, 9:18am UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/2 "2010-11-10T09:18:51Z")

</div>

Hi Erik,

> erikd:
> 
> 1. Is there a way of displaying HTML preview and HTML codes in 2 different types of text area?  
> I tried using TEXT\_AREA to display the HTML source codes but HTML tags were not displayed.

You should be able to show the same dataprovider in different fields at the same time. So a field with display type HTML\_AREA and a field with display type TEXT\_AREA.  
I do this all the time.

> erikd:  
> 2. When using HTML\_AREA to display HTML source codes, can I also embed images? If this is allowed, where should these images reside?

You can reference images in your HTML by way of the ![]() tag, like you do in webpages. These images can reside anywhere that the servoy client can access using the different protocol handlers (http://, https://. file://, media:///, etc.).  
What are you trying to do ? Send emails with embedded images ? Or something else ?

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [November 11, 2010, 10:14pm UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/3 "2010-11-11T22:14:21Z")

</div>

Thanks for this. Yes, I am using it to send emails.

I am figuring out now how to have a tool bar for it.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 12, 2010, 10:29am UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/4 "2010-11-12T10:29:56Z")

</div>

Hi Erik,

When you send HTML email with embedded (attached) images you can simply reference them by name in the HTML like so:

```auto
<img src="attachedfilename.jpg">

```

Of course the image will only render for you when opened up in the (receiving) email client.  
If you want to see the images in your solution before you send it out then you need to reference them differently (depends on what you want to do exactly) and then just before you send the email you automatically replace the references with the correct one.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [November 15, 2010, 10:50pm UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/5 "2010-11-15T22:50:57Z")

</div>

Ok, Thanks! I will test what I got from your post.

One more question, is there a way to get the display values only from an HTML tag?

For example, if I have “\< html \>\< p \> Hello world \< / p \>\< / html \>”, is there an easy way to get “Hello World” only and store it in a variable?

---

<div class="post-metadata">

**Author:** ![david](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@david](https://forum.servoy.com/u/david)\
**Post date:** [November 15, 2010, 10:58pm UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/6 "2010-11-15T22:58:03Z")

</div>

> erikd:  
> For example, if I have “\< html \>\< p \> Hello world \< / p \>\< / html \>”, is there an easy way to get “Hello World” only and store it in a variable?

If you name the html area field, an extra function becomes available that will convert html to text for you. elements.element\_name.htmlToText() or something close (going off the top of my head).

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [November 15, 2010, 11:12pm UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/7 "2010-11-15T23:12:54Z")

</div>

I used getAsPlainText(). It worked ok.

Thanks for the reply.

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [November 16, 2010, 8:35am UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/8 "2010-11-16T08:35:40Z")

</div>

> erikd:  
> I used getAsPlainText(). It worked ok.

For most html it works ok, I’ve seen a couple of really advanced html strings which returned ‘null’ after getAsPlainText().  
So I ended up stripping tags.

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [November 17, 2010, 12:31am UTC](https://forum.servoy.com/t/html-and-source-codes-display/13165/9 "2010-11-17T00:31:47Z")

</div>

You’re right. Manual removal of tags is better.
