SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Updating <p> with an ampersand in IE7

    Hi,

    I have a weird IE7 problem. I have a <p> element which I want to update with some text from a Input.

    If I put the text 'O&O' in the input it only shows 'O' in the <p>. 'O & O' works just fine. I already tried replacing the '&' with '&amp;' but that didn't help. Also updating the element with 'update' function from Prototype.js didn't help. All the different solutions that don't work in IE7 work fine in FF.

    HTML Code:
    <p id="usp1_display"></p>
    
    <input name="usp1" id="usp1" type="text" value="" />
    <input type="button" onclick="$('usp1_display').update($F('usp1'));">
    I'm kinda stuck, does anybody know what I can try next?

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does this work? -

    Code JavaScript:
    document.getElementById('usp1_display').appendChild(document.createTextNode(document.getElementById('usp1').value));
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tested your code Jimmy and it does work. Seems IE7 got the DOM right but not innerHTML ?!?

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JimmyP View Post
    Does this work? -

    Code JavaScript:
    document.getElementById('usp1_display').appendChild(document.createTextNode(document.getElementById('usp1').value));
    Thank you JimmyP for your input but it gives the same result. It cuts the string off after the ampersand. It's driving me nuts!


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
  •