Advertisement
dmilosavleski

4 - 3

Dec 25th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>prva / vtora</title>
  6. <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  7. <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  8. <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
  9. <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  10. <link rel="stylesheet" type="text/css" href="prva.css" />
  11. <script type="text/javascript" src="prva.js"></script>
  12. </head>
  13.  
  14. <style>
  15. body {
  16. font-size: 62.5%;
  17. }
  18. label, input {
  19. display: block;
  20. }
  21. input.text {
  22. margin-bottom: 12px;
  23. width: 95%;
  24. padding: .4em;
  25. }
  26. fieldset {
  27. padding: 0;
  28. border: 0;
  29. margin-top: 25px;
  30. }
  31. h1 {
  32. font-size: 1.2em;
  33. margin: .6em 0;
  34. }
  35. div#users-contain {
  36. width: 350px;
  37. margin: 20px 0;
  38. }
  39. div#users-contain table {
  40. margin: 1em 0;
  41. border-collapse: collapse;
  42. width: 100%;
  43. }
  44. div#users-contain table td, div#users-contain table th {
  45. border: 1px solid #eee;
  46. padding: .6em 10px;
  47. text-align: left;
  48. }
  49. .ui-dialog .ui-state-error {
  50. padding: .3em;
  51. }
  52. .validateTips {
  53. border: 1px solid transparent;
  54. padding: 0.3em;
  55. }
  56. </style>
  57.  
  58.  
  59. <script>
  60. $(function() {
  61. var id = $("#sifra"),
  62. ime = $("#ime"),
  63. proizvoditel = $("#proizvoditel"),
  64. datum = $("#datum").datepicker(),
  65. allFields = $([]).add(id).add(ime).add(proizvoditel),
  66. tips = $(".validateTips");
  67.  
  68. function updateTips(t) {
  69. tips
  70. .text( t )
  71. .addClass( "ui-state-highlight" );
  72. setTimeout(function() {
  73. tips.removeClass( "ui-state-highlight", 1500 );
  74. }, 500 );
  75. }
  76.  
  77. function checkRegexp( o, regexp, n ) {
  78. if ( !( regexp.test( o.val() ) ) ) {
  79. o.addClass( "ui-state-error" );
  80. updateTips( n );
  81. return false;
  82. } else {
  83. return true;
  84. }
  85. }
  86.  
  87. $( "#dialog-form" ).dialog({
  88. autoOpen: false,
  89. height: 400,
  90. width: 350,
  91. modal: true,
  92. buttons: {
  93. "Додади": function() {
  94. var bValid = true;
  95. allFields.removeClass( "ui-state-error" );
  96. bValid = bValid && checkRegexp(id, /^([0-9])+$/i, "Шифрата треба да биде составена единствено од броеви.");
  97.  
  98. if ( bValid ) {
  99. $("#users tbody").append("<tr>" +
  100. "<td>" + id.val() + "</td>" +
  101. "<td>" + ime.val() + "</td>" +
  102. "<td>" + proizvoditel.val() + "</td>" +
  103. "<td>" + datum.val() + "</td>" + "</tr>");
  104.  
  105. $(this).dialog("close");
  106. }
  107. }, "Откажи": function() {
  108. $(this).dialog("close");
  109. }
  110. }, close: function() {
  111. allFields.val( "" ).removeClass( "ui-state-error" );
  112. }
  113. });
  114.  
  115. $( "#create-user" )
  116. .button()
  117. .click(function() {
  118. $( "#dialog-form" ).dialog( "open" );
  119. });
  120.  
  121. });
  122. </script>
  123.  
  124. <body>
  125. <div id="dialog-form" title="Create new flight">
  126. <p class="validateTips">
  127. Сите полиња се задолжителни.
  128. </p>
  129. <form>
  130. <fieldset>
  131. <label for="sifra">Шифра</label>
  132. <input type="text" name="sifra" id="sifra" class="text ui-widget-contentui-corner-all" />
  133. <label for="ime">Авиопревозник</label>
  134. <input type="text" name="ime" id="ime" value="" class="text ui-widget-content ui-corner-all" />
  135. <label for="proizvoditel">До</label>
  136. <input type="text" name="proizvoditel" id="proizvoditel" value="" class="text ui-widget-content ui-corner-all" />
  137. <label for="datum">Класа</label>
  138. <select>
  139. <option value="volvo">Бизнис</option>
  140. <option value="saab">сас</option>
  141. <option value="mercedes">Mдадаercedes</option>
  142. <option value="audi">Auдадdi</option>
  143. </select>
  144. </fieldset>
  145. </form>
  146. </div>
  147. <div id="users-contain" class="ui-widget">
  148. <h1>Постоечки ставки:</h1>
  149. <table id="users" class="ui-widget ui-widget-content">
  150. <thead>
  151. <tr class="ui-widget-header">
  152. <th>Шифра</th>
  153. <th>Авиопревозник</th>
  154. <th>До</th>
  155. <th>Класа</th>
  156. </tr>
  157. </thead>
  158. <tbody>
  159. <tr>
  160. <td>12331</td>
  161. <td>Wizz Air</td>
  162. <td>London</td>
  163. <td>Бизнис</td>
  164. </tr>
  165. </tbody>
  166. </table>
  167. </div>
  168. <button id="create-user">
  169. Додади нова ставка
  170. </button>
  171. </body>
  172. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement