Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Alternative to innerText for Firefox

    I'm using innerText to update values on a quote page when the user click certain checkboxes and i need to know if there is a straightforward alternative to using the IE compatible innerText method in Firefox?

    Here is the function that uses the innerText method:
    Code:
    function setText(pItem, pValue)
    {
      var y;
      var z;
      
      y = document.getElementById(pItem);
      z = y.innerText;
      
      
        
      if (z == pValue)
        {
          y.innerText = 0;
          if (pItem == 'adb') totalABD = 0;
          if (pItem == 'pai') totalPAI = 0;
          if (pItem == 'hcp') totalHCP = 0;
          
          // Start:
          if (pItem == 'ho1') totalHO1 = 0;
          if (pItem == 'ho2') totalHO2 = 0;
          // End:
        }
    
      else {  
      y.innerText = pValue;
      } 
      
      // Start:
      grandTotal = parseFloat(totalABD) + parseFloat(totalPAI) + parseFloat(totalHCP) + parseFloat(totalHO1) + parseFloat(totalHO2);
      // End
       AngrandTotal =(parseFloat(totalABD) + parseFloat(totalPAI) + parseFloat(totalHCP) + parseFloat(totalHO1) + parseFloat(totalHO2)) * 12;
        
      z = document.getElementById('total');
      z.innerText = round(grandTotal);
      
      z1 = document.getElementById('Antotal');
      z1.innerText = round(AngrandTotal);  
    }
    Here is how the function is called when clicking on one of the checkboxes:
    Code:
    <input id="pai_StdSin" type="checkbox" name="pai_StdSin" onClick="javascript:setText('pai', '<%= (session.getAttribute("PricePAStdSin") == null)?"":session.getAttribute("PricePAStdSin") %>');" value="Checked">
    So any ideas what alternative method can be used for Firefox browsers?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Use innerHTML. Both IE and Firefox (and other modern browsers) support it.

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Could also use .textContent.

  • #4
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all your help guys, but i used
    Code:
    firstChild.data
    in the end, which works just fine in FF and IE.


  •  

    Posting Permissions

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