Needing Comma's in my Form Feild's " My example"

C

Crash_beta

Let me show u what I have,, I need to make this work with comma's in
the numbers like 123,000.45

Not just 123000.45



<script type="text/javascript">

<!-- Begin

function startCalc(){

interval = setInterval("calc()",1);

}

function calc(){

one = document.form1.ElecProjCost.value;

two = document.form1.ElecProjBill.value;

four = document.form1.CtrlProjCost.value;

five = document.form1.CtrlProjBill.value;

seven = document.form1.OthrProjCost.value;

eight = document.form1.OthrProjBill.value;

nine = document.form1.BondAm.value;

ten = document.form1.BondBill.value;

elev = document.form1.ElecRem.value;

twlve= document.form1.CtrlProjrem.value;

thrtn = document.form1.OthrProjrem.value;

frtn = document.form1.BondRem.value;

document.form1.ElecRem.value = (one * 1) - (two * 1);

document.form1.CtrlProjrem.value = (four * 1) - (five * 1);

document.form1.OthrProjrem.value = (seven * 1) - (eight * 1);

document.form1.BondRem.value = (nine * 1) - (ten * 1);

document.form1.AllRemainSum.value = (elev * 1) + (twlve * 1) + (thrtn *
1)

}

function stopCalc(){

clearInterval(interval);

}

// End -->

</script>





Then for each form Text Box

<input type="text" class="inp"name="ElecProjCost" value="" size="9"
onkeypress="if(event.keyCode == 13) { event.keyCode = false; return
false; }" onFocus="startCalc();" onBlur="stopCalc();">



<input type="text" class="inp"name="ElecProjBill" value=""
size="9"onkeypress="if(event.keyCode == 13) { event.keyCode = false;
return false; }" onFocus="startCalc();" onBlur="stopCalc();">



<input type="text"class="inp" name="ElecRem" value="" size="9">
 
M

mick white

Crash_beta said:
Let me show u what I have,, I need to make this work with comma's in
the numbers like 123,000.45

Not just 123000.45

function removeCommas(input){return Number(""+input.replace(/,/g,""));

document.form1.ElecRem.value = removeCommas(one) - removeCommas(two);


document.form1.AllRemainSum.value =
removeCommas(elev) + removeCommas(twlve) + removeCommas(thrtn)

Mick
 
D

Dr J R Stockton

In comp.lang.javascript message
function removeCommas(input){return Number(""+input.replace(/,/g,""));
} // !!

Or

function removeCommas(input){return Number( input.replace(/,/g,""))}

function removeCommas(input){return +input.replace(/,/g,"") }
 
M

mick white

Dr said:
In comp.lang.javascript message


} // !!

Or

function removeCommas(input){return Number( input.replace(/,/g,""))}

function removeCommas(input){return +input.replace(/,/g,"") }

The input may be a Number, belt and braces perhaps.

Mick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top