Often when one needs to access the value set in an HTML control from the client side script it is tempting to reach into the DOM object and retrieve it directly, using something like this for example:
var c = document.getElementById('TabControl_element_AccountOpportunities_element_view_AccountOpportunities_AccountOpportunities_InactiveTotal_InputCurrency_CurrencyTextBox'); // this will retrieve the value as a string - still needs to be parsed as a number! var value = c.value;
Then to set the value something like:
// need to implement "formatValue" somehow! c.value = formatValue(value);
The hard-coded id is not great of course but the main problem with the approach in my opinion is the fact that you’ll bypass the localization logic and have to parse / format the numbers yourself. Another potential issue is that because the logic of the “dijit” (the client-side widget used to render and control the currency textbox) is bypassed it will cause its internal state to be inconsistent. Often it is more reliable to access the dijit instead, using code such as:
var c = dijit.byId('TabControl_element_AccountOpportunities_element_view_AccountOpportunities_AccountOpportunities_InactiveTotal_InputCurrency_CurrencyTextBox'); // this will retrieve the "parsed" value as a number var value = c.get('value');
And to set it:
c.set('value', 3000);
If you have some good examples of accessing the controls from client side script please share them in the comments!