I would like to use field.name as the key for the hash table on initialisation but I get an error saying that “:” is missing on init line, here how I tried
var field1 = document.getElementById("PRES_BK_LANG");
var field2 = document.getElementById("PRES_BK_CORR_MED");
var fields = {field1.name:[field1,"P"],field2.name:[field2,"O"]};
can this be done?
Any ideas?
No, the object literal notation is only usable if the property names are hardcoded. You will have to use the object as a map to store your data: