We have just discovered an issue with one of our live project that uses common code to access a certain value.
On one page we have an editable text box and can access the value in jscript using dojo.byId('MyField').value.
On a different form we have made it an output field (same name) BUT dojo.byId('MyField').value return undefined.
Instead the code needs to be changed now (so not so common) to use dojo.byId('MyField').innerText for it to be picked up.
To get around this I'm going to check for value defined first and then revert to innerText if it doesn't.
On one page we have an editable text box and can access the value in jscript using dojo.byId('MyField').value.
On a different form we have made it an output field (same name) BUT dojo.byId('MyField').value return undefined.
Instead the code needs to be changed now (so not so common) to use dojo.byId('MyField').innerText for it to be picked up.
To get around this I'm going to check for value defined first and then revert to innerText if it doesn't.
RE: Difference between Output and Text ox values
Yes you are right that you need to use a different approach for getting the value of an output field compared to an editable control when using custom script. This is due to the different HTML that gets generated for the different fields. (eg a text box will generate an HTML <input type="text"> tag where as an output field will be generated as a <span>.)
One other thing you may need to be aware of is that the innerText property is not available in all browsers, so if you need your application to work cross browser (not just in IE) then you may need to do something like:
if (typeof(field.value) != 'undefined') return field.value; else if (typeof(field.innerText) != 'undefined') return field.innerText; else if (typeof(field.textContent) != 'undefined') return field.textContent;
We do realise that this gets a bit cumbersome, so we have introduced a couple of utility methods for the next release (hyf.util.getFieldValue('field name') and hyf.util.setFieldValue('field name', 'new value')) that handle all the differences between getting and setting the values for all the different types of controls and widgets. These are not available in 3.1.2, but at least going forward with newer WebMaker releases it will be easier to handle these types of issues. :)
Regards,
Gerard
RE: Difference between Output and Text ox values