Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 4.50 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-23-2007, 04:48 PM   PM User | #1
El_Guapo
New to the CF scene

 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
El_Guapo is an unknown quantity at this point
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?
El_Guapo is offline   Reply With Quote
Old 05-23-2007, 05:03 PM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Use innerHTML. Both IE and Firefox (and other modern browsers) support it.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 05-23-2007, 05:31 PM   PM User | #3
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Could also use .textContent.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 05-24-2007, 01:07 PM   PM User | #4
El_Guapo
New to the CF scene

 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
El_Guapo is an unknown quantity at this point
Thanks for all your help guys, but i used
Code:
firstChild.data
in the end, which works just fine in FF and IE.
El_Guapo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:29 PM.


Advertisement
Log in to turn off these ads.