|
| 1 | +<!doctype html> |
| 2 | +<head> |
| 3 | +<title>Simple tables</title> |
| 4 | +<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"> |
| 5 | +<link rel=stylesheet type=text/css href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> |
| 6 | +<link rel=stylesheet type=text/css href="https://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css"> |
| 7 | +<!--<link rel=stylesheet type=text/css href="https://cdn.datatables.net/responsive/1.0.4/css/dataTables.responsive.css"> --> |
| 8 | +</head> |
| 9 | +<body> |
| 10 | + |
| 11 | +<input type='button' id="sa" value='Save'></input> |
| 12 | +<div class=page> |
| 13 | + <!-- <h1>Python</h1> --> |
| 14 | + {% for table in tables %} |
| 15 | + <h2>{{titles[loop.index]}}</h2> |
| 16 | + {{ table|safe }} |
| 17 | + {% endfor %} |
| 18 | +</div> |
| 19 | +<form action="/insert" method="post"> |
| 20 | + <label>Num1</label> <input type="text" name="num1" placeholder="number1"></input> |
| 21 | + <label>Num2</label> <input type="text" name="num2" placeholder="number2"></input> |
| 22 | + <input type="submit" value="Insert"></input> |
| 23 | +</form> |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"> </script> |
| 30 | +<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"> </script> |
| 31 | +<script src="https://cdn.rawgit.com/ejbeaty/CellEdit/master/js/dataTables.cellEdit.js"> </script> |
| 32 | +<script> |
| 33 | +$(document).ready(function() { |
| 34 | + var table = $('#example').DataTable(); |
| 35 | + table.MakeCellsEditable({ |
| 36 | + "onUpdate": myCallbackFunction |
| 37 | + }); |
| 38 | + function myCallbackFunction(updatedCell, updatedRow, oldValue) { |
| 39 | + console.log("The new value for the cell is: " + updatedCell.data()); |
| 40 | + console.log("The old value for that cell was: " + oldValue); |
| 41 | + console.log("The values for each cell in that row are: " + updatedRow.data()); |
| 42 | + updatedCell.data(); |
| 43 | + updatedRow.data(); |
| 44 | + table.draw(); |
| 45 | + } |
| 46 | +}); |
| 47 | +</script> |
| 48 | +<script> |
| 49 | +$("#sa").click(function() { |
| 50 | + $.ajax({ |
| 51 | + url: '/save', |
| 52 | + type: 'POST', |
| 53 | + data : document.documentElement.innerHTML, |
| 54 | + success: function(response) { |
| 55 | + alert('Data is Saved') |
| 56 | + } |
| 57 | + }) |
| 58 | +}); |
| 59 | +</script> |
| 60 | +</body> |
| 61 | +</html> |
0 commit comments