Announcement

Collapse
No announcement yet.

Entity code showing up

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Entity code showing up

    I'm building a template based batch report that includes some javascript.


    <SCRIPT>
    inputTextString="&mvt:option:data;" + "&mvt:option:data_long;"
    alert(inputTextString);
    </SCRIPT>

    If the miva option data contains an ampersand it shows up as entity code in the javascript variable. For example if the option data is A&M the inputTextString shows A&amp;M .

    Anyone know how to prevent this?
    Gary

    [email protected]
    www.icCommerce.com

    #2
    Re: Entity code showing up

    I found several ways to decode HTML entities. I ended up using http://underscorejs.org/# which contains:

    escape_.escape(string)
    Escapes a string for insertion into HTML, replacing &, <, >, ", `, and 'characters.

    _.escape('Curly, Larry & Moe');
    => "Curly, Larry &amp; Moe"

    unescape_.unescape(string)
    The opposite of escape, replaces &amp;, &lt;, &gt;, &quot;, ` and &#x27;with their unescaped counterparts.

    _.unescape('Curly, Larry &amp; Moe');
    => "Curly, Larry & Moe"
    Last edited by gsam; 01-22-15, 12:12 PM.
    Gary

    [email protected]
    www.icCommerce.com

    Comment


      #3
      Entity code showing up - Reply to Topic

      I'm building a template based batch report that includes some javascript. <SCRIPT> inputTextString=&quot;&mvt:option:data;&quot; + &quot;&mvt:option:data_long;&quot; alert(inputTextString); </SCRIPT> If the miva option data contains an ampersand it shows up as entity code in the javascript variable. For example if the option data is A&M the inputTextString shows A&amp;M . Anyone know how to prevent this?
      Sorry for that I interfere ... But I am very close to this topic . I can help with the answer.

      Comment

      Working...
      X