Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function working in FF but not IE - help 1

Status
Not open for further replies.

petermaci

Programmer
Jun 1, 2004
11
0
0
CA
Hello everyone... this code works in Firefox and not IE, any obvious mistakes ?

NOTES:
- round() is a javascript function that works (tried and true)

========= code begins ====================

function get_balance() {

var start_amt = document.forms[0].start_amt_toward_debt.value;
var total_payment = 0;
var percent_owed = 0;
var payment_amt = 0;
var total_owed = 0.00;

for(i=0; i<15; i++) {
myBalance = 'balance'+i;
if(parseFloat(document.getElementById(myBalance).value)) {
total_owed = parseFloat(document.getElementById(myBalance).value) + total_owed ;
}
}
for(i=0; i<15; i++) {
myBalance = 'balance'+i;
myPayment = 'p_payment'+i;
creditor_amt = parseFloat(document.getElementById(myBalance).value);
percent_owed = (creditor_amt / total_owed) ;
payment_amt = (start_amt * percent_owed) ;

if (payment_amt > 0) {
document.forms[0].eval(myPayment).value = round(payment_amt) ;
total_payment += payment_amt ;
} else {
document.forms[0].eval(myPayment).value = '' ;
}
}

document.forms[0].total_balance.value = round(total_owed);
}

========= code ends ====================
 
'not 100% sure, but definitely consider changing:

document.forms[0].eval(myPayment).value

to:

document.getElementById(myPayment).value

'hope that helps.

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
ok... I narrowed it down to this line of code

document.forms[0].eval("p_payment"+i).value = 0;

the eval() works in FF but not IE, any work around for this ?

Peter
 
It is this.
[tt]document.forms[0].elements[myPayment].value[/tt]
 
thank you so much... that was the answer...

I will even give you a star !!!

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top