populatejs.min.js 885 B

1
  1. (function(e){var t=function(e){for(var t in e){var a=e[t];var i=document.getElementsByName(t),n,r;if(i){r=i[0].nodeName.toLowerCase();switch(r){case"input":n=i[0].getAttribute("type");switch(n){case"checkbox":if(a==true||a==false||a=="checked"){i.checked=a}else{a=a.split(",");a.map(function(e){for(var t=0;t<i.length;t++){i[t].value==e?i[t].checked=true:""}})}break;case"radio":for(var o=0;o<i.length;o++){i[o].value==a?i[o].checked=true:""}break;default:i[0].value=a}break;case"select":if(i[0].hasAttribute("multiple")){a=a.split(",");var f=i[0].getElementsByTagName("option");for(var o=0;o<f.length;o++){if(a.indexOf(f[o].value)!=-1){f[o].selected=true}}}else{i[0].value=a}break}}}};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define(function(){return t})}else if(typeof module!=="undefined"&&module.exports){module.exports=t}else{e.populatejs=t}})(this);