I have a form with the usual fields (name, address, details, etc) and this content is saved into a table as name/value pairs. I would then like to repopulate the form at a later date using the name/value pairs to match the content up to the correct form fields.
I have the following code, array just seemed like a sensible choice to easily manage the fields (and I want to re-use the code on other forms).
Code: Select all
var meta_rows = tables.TBL_META.fetchTable();
var fieldsarray = new Array();
fieldsarray[0] = "FRM_TITLE";
fieldsarray[1] = "FRM_FIRSTNAME";
fieldsarray[2] = "FRM_LASTNAME";
fieldsarray[3] = "FRM_ADDRESS1";
fieldsarray[4] = "FRM_ADDRESS2";
fieldsarray[5] = "FRM_ADDRESS3";
fieldsarray[6] = "FRM_ADDRESS4";
fieldsarray[7] = "FRM_POSTCODE";
fieldsarray[8] = "FRM_TELEPHONE";
fieldsarray[9] = "FRM_EMAIL";
fieldsarray[10] = "FRM_DETAILS";
fieldsarray[11] = "FRM_DETAILS_MORE";
fieldsarray[12] = "FRM_OTHER_DETAILS";
while (meta_rows.next()){
if ( system.executeCustomFunction("contains", [tables.TBL_META.FLD_ID.value, "FRM_"])){
if ( tables.TBL_META.FLD_STRING_ID.value == 0 ){
for (var i=0; i < fieldsarray.length; i++){
var fieldname = "fields."+fieldsarray[i]+".value";
if ( tables.TBL_META.FLD_ID.value == fieldsarray[i] ){
var x = fieldname + "='" + tables.TBL_TESTCRM_PPCALLMETADATA.FLD_VAL.value + "';";
eval('x');
}
}
} // somethig else here
}
}
Please forgive any coding bad practice, I am pretty damn new to Javascript so learning as I go.