Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Util = {};
- //
- // getElemValues
- //
- // pass it a map of (name => htmlelemid) pairs
- // will return a map (object) containing pairs of (name => htmlelem.value)
- //
- // Example:
- // getElemValues({name: "nameinput", address: "addressinput"})
- //
- // will return:
- // {name: document.getElementById("nameinput").value,
- // address: document.getElementById("addressinput").value}
- //
- Util.getElemValues = function getElemValues(propElemMap){
- if(Util.log) Util.log.debug("get elem values called.");
- var return_obj = {};
- for(var prop in propElemMap){
- var id = propElemMap[prop];
- var obj = document.getElementById(id);
- if(obj){
- return_obj[prop] = obj.value != ""? obj.value : null;
- }
- else{
- if(Util.log) Util.log.error("no element with id = '" + id +"'")
- }
- }
- return return_obj;
- }
Add Comment
Please, Sign In to add comment