www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 06-24-2007, 04:15 PM
    derk_the_zeeman derk_the_zeeman is offline
    Registered User
     
    Join Date: May 2006
    Posts: 21
    My .innerHTML for one part of my program is not working!

    Please explain this problem to me if you can??


    1 var str = 'The Raven G&CC';
    2 idname = 'SPcodename' + q;");
    3 alert(str+' !');");
    4 document.getElementById('idname').innerHTML = str;
    5 alert(document.getElementById('idname').innerHTML + ' !');

    As you can see a very simple javascript code snippet.
    This program use to work but not anymore.
    The problem is that when the first alert is shown I get the proper string showing in the box 'The Raven G&CC !', but in line 4 when the str variable gets set to the id 'idname' tag.innerHTML the content of the string gets severed right after the 'G' and the only part of the string to get displayed is 'The Raven G'. When I alert it in line 5 I get the same result 'The Raven G !'.

    This program use to work and I did not get this problem. I tried changing the & to another variable and it worked ie ('The Raven GVCC !'), but it should work for all string characters and I need the &. Also I have other coded areas in my program where I set a string to an .innerHTML tag with an ampersand(&) and it works fine. It is just for this group of HTML tags for some reason. It is like somebody has put a resident program in my program which is not in my view to see or decipher. I thought that somebody might have a program which, unbenounced to me, saves another copy similar but with some additions to my program when I compile it but when I view the source code it is the same as my original code. Anyway, if you can tell me how I can get the 'The Raven G&CC' string to display in the above .innerHTML tag. I will deem you a genious!

    Thanks for the interest in my problem and possible solution.

    Derek
    Reply With Quote
      #2  
    Old 06-24-2007, 04:54 PM
    HazardTW HazardTW is offline
    Registered User
     
    Join Date: Apr 2007
    Posts: 152
    "); <-- This at the end of lines 2 & 3 should not be there unless you did not post the full code. Every closing brace needs an opening brace, same with quotes.

    Also remove the quotes from around your variable idname where it is used to get element by id. document.getElementById('idname') is looking for an element with the id='idname' literally, change to document.getElementById(idname).

    Try this: (although make sure that you have an element with id that equals 'SPcodename' + q, can't tell what q equals from the code you supplied)

    Code:
    var str = 'The Raven G&CC';
    idname = 'SPcodename' + q;
    alert(str+' !');
    document.getElementById(idname).innerHTML = str;
    var i = document.getElementById(idname).innerHTML.replace(/&amp;/g,"&")
    alert(i + ' !');

    Last edited by HazardTW; 06-24-2007 at 05:09 PM.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:32 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.