Found this ancient thread while trying to resolve issue with ‘selectAll()’
Trying to grab field name + data pairs on a Form and paste them into a text field for later re-use.
Hard coding the field name works but using a variable crashes out. Am I missing something obvious???
Function b_GetFields()
{
var vElemArray = alldataproviders;
var vField = null;
var vData = null;
for (var i=0 ; i<vElemArray.length ; i++)
{
vField = vElemArray[i];
//*** this does not work - stops debgger at vData line
elements[vField].selectAll();
vData = elements[vField].getSelectedText();
//*** this works as expected
// elements.company_name.selectAll();
// vData = elements.company_name.getSelectedText();
// .... paste into TextField...
}
Are you able to suggest what the code should be to get the FieldName & Data pairs? I’ve tried so many code variations this afternoon that can’t think how to do it.
If you’re trying to store edited data that is not saved yet, you can look at the functions under the databaseManager that allow you to get all unsaved data.
If you want to get the data from the fields, you can loop though the elements, check if they are a field, then get the dataprovider and with that the current value.
If you want the data of the current record, just get the record from the foundset.
If you want to get the data from the fields, you can loop though the elements, check if they are a field, then get the dataprovider and with that the current value.
Everyone probably knows this by now, but for the newbies out there (like me) …
You can set the dataprovider of a field to a form variable and then the form variable changes when the field does and vise-versa. It’s not as intuitive as elements.myDetachedField.text = “blah”, but it works well. It is probably wise to never leave a dataprovider set at “None”.