Guest User

Untitled

a guest
Jun 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. var Util = {};
  2.  
  3. //
  4. // getElemValues
  5. //
  6. // pass it a map of (name => htmlelemid) pairs
  7. // will return a map (object) containing pairs of (name => htmlelem.value)
  8. //
  9. // Example:
  10. // getElemValues({name: "nameinput", address: "addressinput"})
  11. //
  12. // will return:
  13. // {name: document.getElementById("nameinput").value,
  14. // address: document.getElementById("addressinput").value}
  15. //
  16. Util.getElemValues = function getElemValues(propElemMap){
  17. if(Util.log) Util.log.debug("get elem values called.");
  18.  
  19. var return_obj = {};
  20.  
  21. for(var prop in propElemMap){
  22. var id = propElemMap[prop];
  23. var obj = document.getElementById(id);
  24. if(obj){
  25. return_obj[prop] = obj.value != ""? obj.value : null;
  26. }
  27. else{
  28. if(Util.log) Util.log.error("no element with id = '" + id +"'")
  29. }
  30. }
  31.  
  32. return return_obj;
  33. }
Add Comment
Please, Sign In to add comment