|
|
|
ช่วยแก้ไขหน่อยครับ javascript เติม comma (คอมมา) , กับ . ให้ตัวเลข |
|
|
|
|
|
|
|
...
|
|
|
|
|
Date :
2011-10-09 18:40:41 |
By :
ihusky27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
....
|
|
|
|
|
Date :
2011-10-09 20:21:08 |
By :
ihusky27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script language="JavaScript">
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
function chkNum(ele)
{
//var num = parseFloat(ele.value);
var num = parseFloat(ele.value.replace(/,/g,''));
ele.value = addCommas(num.toFixed(2));
}
</script>
<input name="salary" type="text" id="salary" style="width:200px; text-align:right" value="" onchange="JavaScript:chkNum(this)" />
|
|
|
|
|
Date :
2011-10-09 21:28:19 |
By :
num |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำได้แล้ว ขอบคุณมากๆครับ
|
|
|
|
|
Date :
2011-10-10 23:13:43 |
By :
ihusky27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|