468,458 Members | 1,887 Online

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

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

Dec 11 '06 #1
3 1330
Crash_beta wrote:
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

>
<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">
Dec 12 '06 #2
In comp.lang.javascript message
<QF******************@twister.nyroc.rr.com>, Tue, 12 Dec 2006 00:25:20,
mick white <mi**@mickweb.comwrote:
>
function removeCommas(input){return Number(""+input.replace(/,/g,""));
} // !!

Or

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

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

--
(c) John Stockton, Surrey, UK. REPLYyyww merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Dec 12 '06 #3
Dr J R Stockton wrote:
In comp.lang.javascript message
<QF******************@twister.nyroc.rr.com>, Tue, 12 Dec 2006 00:25:20,
mick white <mi**@mickweb.comwrote:
>>function removeCommas(input){return Number(""+input.replace(/,/g,""));

} // !!

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

Dec 13 '06 #4

### This discussion thread is closed

Replies have been disabled for this discussion.