开发者

How to set a control's DataValue to a number in MS Dyanamics CRM 4.0?

I need to set the value of a field in a form via JavaScript. The source of the data is from another source, via an IFRAME. I'm running this code in the onload of the ASPX page in the IFRAME:

// Get value from source
var currencyText = document.getElementById("contractValue").value;

// Convert that value to a number, stripping out non-number cha开发者_StackOverflow社区racters.
var currencyNumber = new Number(currencyText.replace(/[^0-9\.]+/g,""));

//  Set the value in the CRM field.
parent.crmForm.all.targetCurrencyField.DataValue = currencyNumber;

When I do this I get an message "This control only accepts numbers or null as input". What is the acceptable way to load a value into a currency field in MS CRM?


Try this instead

//strip non numeric characters from currencyText
parent.crmForm.all.targetCurrencyField.DataValue = parseInt(currencyText)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜