SwVitaliy

Untitled

Aug 1st, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function trueRefreshSelects(sels, vals) {var names = []; sels.each(function(){console.log(0);
  2. var $this = $(this);
  3. var prev = $this.prev();
  4. if (!$this.attr('name')) return undefined;
  5. if (!prev.hasClass('selectArea')) return undefined; console.log('1', $this.attr('name'));
  6. var m = prev.attr('id').match(/\d+$/); if (m.length === 0) return undefined; console.log('2', prev.attr('id'), m);
  7. var index = m[0];
  8. prev.remove();
  9. $this.find('option').remove();
  10. var b, d;
  11. do { d = document.getElementById("optionsDiv"+5); b = d != null; if (d) d.parentNode.removeChild(d); } while (b);console.log('3');
  12. var i, str = ''; for (i in vals) { if (!vals.hasOwnProperty(i)) continue; str+= '<option value="{index}">{value}</option>'.replace('{index}', i).replace('{value}', vals[i]) }
  13. $(str).appendTo($this);
  14. names.push($this.attr('name'));
  15. });
  16. refreshSelects(names);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment