Guest User

Untitled

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // TODO: Remove this once it's added to MooTools code
  2. Element.implement({
  3. toFormHash: function(){
  4. var formHash = $H();
  5. this.getElements('input, select, textarea', true).each(function(el){
  6. if (!el.name || el.disabled) return;
  7. var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){
  8. return opt.value;
  9. }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;
  10. $splat(value).each(function(val){
  11. if (typeof val != 'undefined')
  12. formHash.set(el.name, val);
  13. });
  14. });
  15. return formHash;
  16. }
  17. });
Add Comment
Please, Sign In to add comment