Need to correctly render html tags

110 views Asked by At

I know this question might have been asked before, but I have not yet found a way to solve my issue.

On this page, if you click on Webster on the left, you can see the part that says <b>test html</b><br />. I need that to be rendered correctly on the page.

Here is the data that gets saved to the database: &lt;b&gt;test html&lt;/b&gt;&lt;br /&gt;

And here is how I display it on the page (the problematic area is store_details):

contentPane.html('');

html = '<div onclick="showStoreDetails(\'item_store_'+j+'\')" class="custom-location-wrapper"><div class="wk_st_product_gen" id="item_store_'+ j +'" onmouseout="offhighlightMarker('+j+')" onmouseover="highlightMarker('+j+')" onclick="showcontent(\''+store_title+'\',\''+store_address+'\',\''+store_link+'\',\''+j+'\')"><input type="hidden" class="position" id="'+str_dis;
html+= '"><input type="hidden" id="str_lati" value="'+store_latitude;
html+= '"><input type="hidden" id="str_longi" value="'+store_longitude;
html+= '"><div class="store_info"><img alt="store" src="<?php echo HTTP_SERVER;?>image/webkul-store-locater/'+store_image;
html+= '"> <div class="store_address"><div class="store_title">'+store_title;
html+= '</div><div class="store_details"><p class="store_addressline" >'+store_address;
html+= '</p><p class="store_locality">'+store_local;
html+= '</p><p class="store_distance">'+store_distance;
html+= '</p><p>'+store_details;
html+= '</p></div></div></div></div>';
html+= '<style>#alert_red{display:none;}</style>';

contentPane.append(html);
2

There are 2 answers

0
L105 On BEST ANSWER

You can just use html_entity_decode in PHP to decode you data before retrieving it.

us3.php.net/html_entity_decode

0
imcg On

Take a look at the Lo-Dash library (based on underscore). It has an _.unescape method that does this:

http://lodash.com/docs#unescape

html+= '</p><p>'+_.unescape(store_details);