You need to sign in to do that
Don't have an account?
To remove comma on number field
Hi
In visualforce page, i am displaying the Number(16,2) fields of salary, wages etc. currently its displaying like this 10,000.00
i need it without comma for i am adding these values dynamically and save on gross pay number field. during addition it takes first two digits of before comma, it takes 10,000.00 as 10. Is there any idea to solve this issue.
thank you.
Hi Shiva,
var cc3= parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Bonus:Bonus1}').value).replace (/,/g, ""));
this syntax will return values without comma. Below is code which will solve your purpose:
var cc3;
if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Salary:Salary1}').value!=''){
cc3=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Salary:Salary1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Wages:Wages1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Wages:Wages1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Additions:Additions1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Additions:Additions1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Allowance:Allowance1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Allowance:Allowance1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Benefits:Benefits1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Benefits:Benefits1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Bonus:Bonus1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Bonus:Bonus1}').value).replace (/,/g, ""));
}
assign cc3 variable to your gross pay variable and it will work.
Please visit below url for demo.
demo for addition of fields using javascript
Suggestion: instead of using javasript for adding all values, use <apex:actionsupport> and call controller method to do all this operation and then render the pageblock.
Hope this will help you.
[If it solves your problem, please mark it as solution]
All Answers
Hi Shiva,
If you just want to remove comma from display then use <apex:inputtext> or <apex:outputtext> on vf page instead of <apex:inputfield> or <apex:outputfield>.
Can you please post your code which will give clear idea of your problem?
page:
Javascript:
Hi Shiva,
var cc3= parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Bonus:Bonus1}').value).replace (/,/g, ""));
this syntax will return values without comma. Below is code which will solve your purpose:
var cc3;
if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Salary:Salary1}').value!=''){
cc3=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Salary:Salary1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Wages:Wages1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Wages:Wages1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Additions:Additions1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Additions:Additions1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Allowance:Allowance1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Allowance:Allowance1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Benefits:Benefits1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Benefits:Benefits1}').value).replace (/,/g, ""));
}if(document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Bonus:Bonus1}').value!=''){
cc3+=parseFloat((document.getElementById('{!$Component.theForm:EditPayrollPeriodCalc:payrollsection:Bonus:Bonus1}').value).replace (/,/g, ""));
}
assign cc3 variable to your gross pay variable and it will work.
Please visit below url for demo.
demo for addition of fields using javascript
Suggestion: instead of using javasript for adding all values, use <apex:actionsupport> and call controller method to do all this operation and then render the pageblock.
Hope this will help you.
[If it solves your problem, please mark it as solution]
Thank you. Its adding correctly with and without comma
I have the same issue, when I create a custom "Number" field. Instead of a number like 123456 it's giving me 123,456. How do I resolve this one.
Thanks!