edit_user.js.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <script>
  2. function randomString() {
  3. var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
  4. var string_length = 10;
  5. var randomstring = '';
  6. for (var i = 0; i < string_length; i++) {
  7. var rnum = Math.floor(Math.random() * chars.length);
  8. randomstring += chars.substr(rnum, 1);
  9. }
  10. document.v_edit_user.v_password.value = randomstring;
  11. }
  12. $(document).ready(function(){
  13. $('.add-ns-button').click(function(){
  14. var n = $('input[name^=v_ns]').length;
  15. if(n < 8){
  16. var t = $($('input[name=v_ns1]').parents('tr')[0]).clone(true, true);
  17. t.find('input').attr({value:'', name:'v_ns'+(n+1)});
  18. t.find('span').show();
  19. $('tr.add-ns').before(t);
  20. }
  21. if( n == 7 ) {
  22. $('.add-ns').hide();
  23. }
  24. });
  25. $('.remove-ns').click(function(){
  26. $(this).parents('tr')[0].remove();
  27. $('input[name^=v_ns]').each(function(i, ns){
  28. $(ns).attr({name: 'v_ns'+(i+1)});
  29. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  30. });
  31. $('.add-ns').show();
  32. });
  33. $('input[name^=v_ns]').each(function(i, ns){
  34. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  35. });
  36. });
  37. </script>