- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 11:28 AM
This seems like it should be simple...
I have an onChange client script running when one one of my fields changes, and for some reason, the integer field will only accept numbers up to 999. It rounds 1,000 down to 1. Not sure if my code is wrong, or there is something I am not aware of.
function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue == '') { return; } //adds all estimates together and puts them into the est. total field var req = parseInt(g_form.getValue('u_act__requirements'),10); var des = parseInt(g_form.getValue('u_act__design'),10); var dev = parseInt(g_form.getValue('u_act__dev_config'),10); var itt = parseInt(g_form.getValue('u_act_it_test'),10); var newtotal = req + des + dev + itt; g_form.setValue('u_act__total', newtotal); } }}
If I enter 1-999 in the u_act_xxx fields, it works with no issues. As soon as you enter 1000 or anything over 1000, it mucks things up.
Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 12:18 PM
The parseInt command stops processing at the comma. On the server side, you can use .getXMLValue() to get the number without a comma. But on the client side, one solution is to add the attribute "format=none" on the dictionary entry for that field. This will stop the comma from being displayed, and thus read by the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 11:33 AM
I don't suppose you have to declare the variable "newtotal" to be a type of integer, do you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 11:56 AM
Same result using this.
var newtotal = 0;
newtotal = req + des + dev + itt;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 12:09 PM
Any particular reason you're using the radix parameter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 12:13 PM
After you define each of those parseint variables, you could post an alert so you can be sure you're not getting any NaNs. But I don't know why you'd get a NaN for >999 numbers and not for <999