Advertisement
IngeniousA

Untitled

Jan 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Title</title>
  6.     <script
  7.               src="https://code.jquery.com/jquery-3.3.1.js"
  8.               integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
  9.               crossorigin="anonymous"></script>
  10. </head>
  11. <body>
  12.     <h1>PRIVET {{author}}</h1>
  13.  
  14.  
  15.     <form action="/" method="POST">
  16.         {% csrf_token %}
  17.         {{form.first.label}}: {{form.first}}
  18.         {{form.second.label}}: {{form.second}}
  19.         <input type="submit" value="Submit">
  20.     </form>
  21.  
  22.     <table>
  23.   <thead>
  24.     <tr>
  25.       <th scope="col">#</th>
  26.       <th scope="col">date</th>
  27.       <th scope="col">first</th>
  28.       <th scope="col">second</th>
  29.       <th scope="col">result</th>
  30.       <th scope="col">author</th>
  31.       <th scope="col">action</th>
  32.     </tr>
  33.   </thead>
  34.   <tbody>
  35.     {% for calc in history %}
  36.       <tr id="{{calc.id}}">
  37.           <th scope="row">{{calc.id}}</th>
  38.           <td> {{calc.date}}</td>
  39.           <td>{{calc.first}}</td>
  40.            <td>
  41.                     {{calc.second}}
  42.                 </td>
  43.                 <td>
  44.                     {{calc.result}}
  45.                 </td>
  46.                 <td>
  47.                     {{calc.author}}
  48.                 </td>
  49.           <td>
  50.                <button onclick="calc_del({{ calc.id }})")>DELETE</button>
  51.           </td>
  52.       </tr>
  53.     {% endfor %}
  54.  
  55.   </tbody>
  56. </table>
  57.  
  58. <script>
  59.     function calc_del(id)
  60.     {
  61.         $.ajax({
  62.                 type: "POST",
  63.                 url: 'calc_history/delete',
  64.                 data:{
  65.                     id: id,
  66.                     csrfmiddlewaretoken: '{{ csrf_token }}',
  67.                 },
  68.                 success: function(response){
  69.                     x = document.getElementById(JSON.stringify(id))
  70.                     x.remove()
  71.                 }
  72.                 });        
  73.     }
  74. </script>
  75.  
  76. </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement