Advertisement
Guest User

Untitled

a guest
Jan 14th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1.  
  2. @{ Layout = "~/_MasterLayout.cshtml"; }
  3. <!DOCTYPE html>
  4.  
  5. <html lang="en">
  6. <head>
  7. <meta charset="utf-8" />
  8. <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
  9. <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
  10. <script type="text/javascript">
  11.  
  12. $(document).ready(function () {
  13.  
  14. $("input[type='checkbox']").click(function () {
  15.  
  16. var tr = $(this).parents('tr').remove();
  17. var tableId = $(this).parents('table').attr('id');
  18. if (tableId == 'firsttable') {
  19. $('#secondtable tbody').append(tr);
  20. } else {
  21. $('#firsttable tbody').append(tr);
  22. $("#firsttable .del").remove();
  23. }
  24.  
  25.  
  26. });
  27.  
  28. $("#input_button").click(function () {
  29. var $str = $('#input_text').val()
  30. $('#input_text').val(' ')
  31. // document.getElementById('firsttable').innerHTML += '<tr><td><input type="checkbox" id ="'+$str+'"></td><td><p>'+$str+'</p></td><td class="del"><input type="button" id="input_button" value="X"></td></tr>'
  32. var tds = '<tr><td><input type="checkbox" id ="' + $str + '" name=""></td><td><p>' + $str + '</p></td></tr>'
  33. if ($('tbody', '#firsttable').length > 0) {
  34. $('tbody', '#firsttable').append(tds);
  35. } else { $('#firsttable').append(tds); }
  36. });
  37.  
  38. $('.del').click(function () {
  39. $(this).parents('tr').remove();
  40. });
  41. });
  42.  
  43. </script>
  44. </head>
  45. <body>
  46.  
  47. <input type="text" id="input_text">
  48. <input type="button" id="input_button" value="Добавить">
  49. <p>Нужно сделать</p>
  50. <table id="firsttable">
  51. <tr id="check1"><td>@Html.CheckBox("Chek1",false)</td><td><p>Повторить теорию</p></td></tr>
  52. <tr><td>@Html.CheckBox("Chek2",false)</td><td><p>Сдать экзамен</p></td></tr>
  53. <tr><td>@Html.CheckBox("Chek3",false)</td><td><p>Купить торт</p></td></tr>
  54. </table>
  55. <p>Сделано</p>
  56. <table id="secondtable">
  57. <tr id="check1"><td>@Html.CheckBox("Chek4",true)</td><td><p>Весело провести новый год, Рождество</p></td><td></td><td class="del"><input type="button" id="input_button" value="X"></td></tr>
  58. </table>
  59.  
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement