views:

118

answers:

2

Hello, I'm using document.nodeName.innerHTML to change the content of a particular node. It is not working in my case. Can someone please let me know where I've went wrong.Thanks in advance. Please find the below code. On click of a link, I need to change the text of that link.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title> New Document </title>
 </head>
 <body>
    <script type="text/javascript">
     var currentDOMId="";
     var currentPrefKey="";
      function SimpleJSPortlet(id, window) {
       this.id = id;
       this.window = window;
       this.nodeId="";
       this.prefKey="";
       }
    function handleLoadPortletPreferences (portletWindow, status, portletPrefs) { 
     alert("CURRENT DOM ID"+currentDOMId);
     alert(document.getElementById('Aircraft').innnerHTML);
     document.getElementById('Aircraft').innnerHTML="Remove from Favorite";
    }
       SimpleJSPortlet.prototype.addListItem = function (key,value,nodeId) {
       currentDOMId=nodeId;
       currentPrefKey=key;
       handleLoadPortletPreferences();
       }
    </script>
    <style type="text/css">
     #productPreferncesDetails dt{
      color:#000000;
     }
    </style>
    <div id="productsPreferences" style="left: 0pt; width: 100%;">
     <table border="1" cellpadding="0" cellspacing="0" height="100" width="100%">
      <tbody>
       <tr valign="top">
        <td style="padding-left: 15px;">
         <b>Aviation Insurance</b>
         Aircraft
         <a id="Aircraft" href="javascript:void(0);" onclick="simpleJSPortlet7_21602B8280FH00I41OSVRO10G3.addListItem('Aircraft','javascript:void(0);','Aircraft');">Add to Favorites</a>
        </td>
       </tr>
      </tbody>
     </table>
    </div>
    <div id="show7_21602B8280FH00I41OSVRO10G3">
     <!-- Show dynamic HTML here -->
    </div>
    <div id="programmatic">
    </div>
    <script type="text/javascript">
       var portletWindow7_21602B8280FH00I41OSVRO10G3= "";
       var simpleJSPortlet7_21602B8280FH00I41OSVRO10G3= new SimpleJSPortlet("7_21602B8280FH00I41OSVRO10G3", portletWindow7_21602B8280FH00I41OSVRO10G3);
 </script>
 </body>
 </html>
+9  A: 

It's a typo. You have innnerHTML instead of innerHTML

x2
"Type" is a typo. ;)
Guffa
Awww `@Traveling Tech Guy`. Should have just left the type alone.
Crescent Fresh
A: 

Typo in several places as x2 mentions - just to add some content, if you are using firebug, the console.log(...) calls are much more friendly than alerts for debugging, and don't interupt normal document flow in the same way as an alert or confirm.

Code below to demonstrate, remember this is just when console is open for firebug, will cause an error otherwise.

function handleLoadPortletPreferences (portletWindow, status, portletPrefs) { 
        console.log("CURRENT DOM ID"+currentDOMId);
        console.log(document.getElementById('Aircraft').innerHTML);
        document.getElementById('Aircraft').innerHTML="Remove from Favorite";
    }
danp
Thank you very much for your kind reply. I don't understand why the browsers didn't throw and JS errors with this typo.:)
Deepa