...

View Full Version : Alternative to innerText for Firefox



El_Guapo
05-23-2007, 05:48 PM
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:

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:

<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?

glenngv
05-23-2007, 06:03 PM
Use innerHTML. Both IE and Firefox (and other modern browsers) support it.

jkd
05-23-2007, 06:31 PM
Could also use .textContent.

El_Guapo
05-24-2007, 02:07 PM
Thanks for all your help guys, but i used
firstChild.data in the end, which works just fine in FF and IE.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum