Jump to content

Javascript not doing what i want it to do! Please help


eva21

Recommended Posts

I have a textbox for example:

 

<input type=text size="6" MAXLENGTH="6" id="txt1" onchange="doCalcCost()" name="txt1" value="">

 

There is like 6 of them....the user types in a 3, and the doCalcCost function is activated and makes the number 3 a $3.00. What i want to do after all 6 of them have decimal places, i want to put in my total text box the total where i do calculations, but it doesnt work. Please help

 

if(txt1)

{

txt2 = txt1.toFixed(2);

document.getElementById("txt1").value = "$" + txt2;

}

if(txt1 && txt2 && txt3 && txt4 && txt5)

{

var total = 0;

var cents = 0;

.....calculations

//put it back into the total

document.getElementById("totalCost").va... = "$" + total2;

}

 

  • 3 months later...

Fixed:

if(txt1)
{
txt2 = txt1.toFixed(2);
document.getElementById("txt1").value = "$" + txt2;
}
if(txt1 && txt2 && txt3 && txt4 && txt5)
{
var total = 0;
var cents = 0;
document.getElementById("totalCost").va = "$" + total2;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.