This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi I am struggling with a problem I have a text box name amount in which user put amount in simple format like 100000
now my requirement is to change this 10000 in 100,000.00 format meaning I need I ',' after every 3 digit plue in the end .00 must be added into the digit. For this I tried lots of ways like java scipt, try to change it on my bean,sciptlet but it won't work(or may be I am not doing it correctly). Need help to change this digit on my jsp page ....
1) You manipulate the value but never set it back to the input element.
2) You set the variable "x" to one inside the loop every iteration, so it will never equal three.
3) You set the variable "number" only to the current digit plus a comma, and then only when x == 3 (which will never happen).
4) This starts the counting-by-three operation at the beginning of the value--but that's not actually what you want, otherwise you might end up with "123,4.69".
Fix those problems first. Remember that your goal is to build a new value with all of the contents of the old value, but with an additional comma every three numbers.
This code is so short there's no reason to use alert boxes (or anything else for that matter)--work it through in your head, along with some paper and a pen or pencil.