SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    USA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting an Input Value with a Numeric Character Escape

    Anyone know how I can have a javascript setting a form input text with numeric character escapes displaying the character instead of displaying &#xxxx;? It seems to work fine when I set the actual input value field to the escape values but not when I use docment.form.input.value.

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you set an escaped value with script, use unicode escapes.

    Otherwise you need to rewrite the whole input element, including the html escape as its value,
    to the innerHTML of the parent of the input element, and that is tiresome.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var inp = document.getElementById("foo");
    inp.value = "\u20ac";
    This will populate the field with a Euro sign (U+20AC).
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    USA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works. Thank you.


Bookmarks

Posting Permissions

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