caparol6991

Untitled

Jul 22nd, 2020
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  2. <style>
  3. table.pay {
  4. width: auto;
  5. float: right;
  6. /* text-align: right; */
  7. }
  8. #discountDiv {
  9. float: right;
  10. }
  11. </style>
  12. <form action="../pay/" method="POST">
  13. {% csrf_token %}
  14. <input type="radio" id="first" name="browser" onclick="myFunction(this.value)" value="20.00" checked="checked">Kurier Inpost - 20 zł<br>
  15. <input type="radio" name="browser" onclick="myFunction(this.value)" value="40.00">Poczta Polska - 40 zł<br>
  16. <input type="radio" name="browser" onclick="myFunction(this.value)" value="30.00">Kurier - 30 zł<br>
  17. <input type="radio" name="browser" onclick="myFunction(this.value)" value="200.00">Dostawa z większymi gabarytami - 200 zł<br>
  18. <br>
  19. <table class="pay">
  20. <tr>
  21. <td>
  22. Rabat:
  23. </td>
  24. <td>
  25. -{{ rabats }}
  26. </td>
  27. </tr>
  28. <tr>
  29. <td>
  30. Razem do zapłaty:
  31. </td>
  32. <td>
  33. <span id="result" class="context"> {{ total }} zł </span>
  34. </td>
  35. </tr>
  36. </table>
  37. <div style="clear:both"></div>
  38. <div id="discountDiv">
  39. <span>Wprowadź kod:</span>
  40. <input type="text"/> <button id="rabatAjax">Aktywuj</button>
  41. </div>
  42. </tr>
  43. <p class="hypertext"> </p>
  44. <p class="hypertext">
  45. </p>
  46.  
  47. <input id="rabat1" name="rabat1" type="hidden" value="{{ rabats }}"/>
  48. <input id="price" name="price" type="hidden" value="{{ total }}"/>
  49. <input id="price2" name="price2" type="hidden" value=""/>
  50. <br>
  51. <div id="buttons">
  52. <div><a href="{% url 'Home' %}" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Powrót</a></div>
  53. <div><input type="submit" class="btn btn-primary btn-lg active positions" value="Zapłać"></div>
  54. </div>
  55. </form>
  56.  
  57. <script>
  58. $( "#rabatAjax" ).click(function( event ) {
  59. event.preventDefault();
  60. var obj = new Object();
  61. obj.discount = document.getElementById("rabatAjax").value;
  62. var jsonString= JSON.stringify(obj);
  63. $.ajax({
  64. type: 'POST',
  65. url: "/endpointzrabatami",
  66. data: jsonString,
  67. dataType: 'json',
  68. contentType: 'application/json; charset=utf-8'
  69. }).done(function(data) {
  70. if(data.discount != null){
  71. console.log("tutaj dolicz discount");
  72. }
  73. });
  74. });
  75.  
  76. </script>
RAW Paste Data