Advertisement
Latkoski

Форма

Nov 27th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>lab4zadaca3</title>
  6.     <script src="jquery.js"></script>
  7.     <script src="jquery-ui.js"></script>
  8.     <link rel="stylesheet" href="jquery-ui.css">
  9.     <script>
  10.         $(document).ready(function() {
  11.             $( "#dialog" ).dialog({
  12.                 modal: true,
  13.                 autoOpen: false,
  14.                 resizable: false,
  15.                 height:270,
  16.  
  17.                 buttons: {
  18.                     Додади: function() {
  19.                         validateForm();
  20.                         $( this ).dialog( "close" );
  21.                     },
  22.                     Откажи: function() {
  23.                         $( this ).dialog( "close" );
  24.                     }
  25.                 }
  26.             });
  27.             function validateForm() {
  28.                 var $sifra = document.forms["dialog"]["sifra"].value;
  29.                 var $prevoznik = document.forms["dialog"]["prevoznik"].value;
  30.                 var $do = document.forms["dialog"]["do"].value;
  31.  
  32.  
  33.                 if ($sifra=="" || $prevoznik == "" || $do == "") {
  34.                     window.alert("Сите полиња се задолжителни");
  35.                 } else {
  36.                     var flag = true;
  37.                     for (var i = 0 ; i < $sifra.length ; i++) {
  38.                        if ($sifra.charAt(i) < '0' || $sifra.charAt(i) > '9') {
  39.                             flag = false;
  40.                             break;
  41.                         }
  42.                     }
  43.                     if (flag == true) {
  44.                         var $selectedValue = $("#selekt option:selected").text();
  45.  
  46.  
  47.                         $( "tbody" ).append( "<tr>" +
  48.                                 "<td>" + $sifra + "</td>" +
  49.                                 "<td>" + $prevoznik + "</td>" +
  50.                                 "<td>" + $do + "</td>" +
  51.                                 "<td>" + $selectedValue + "</td>" +
  52.                                 "</tr>" );
  53.  
  54.                     } else {
  55.                         window.alert("Шифрата мора да е составена само од цифри");
  56.                     }
  57.                 }
  58.                 document.getElementById("dialog").reset();
  59.             }
  60.             $("#buton").click(function() {
  61.                 $("#dialog").dialog("open");
  62.             });
  63.         });
  64.     </script>
  65.  
  66.     <style >
  67.         body {
  68.             font-size: 10px;
  69.         }
  70.         #users-contain table {
  71.             border-collapse: collapse;
  72.             width: 20px;
  73.         }
  74.         #users-contain table td,#users-contain table th {
  75.             border: 1px solid #eee;
  76.             padding: 6px 10px;
  77.             text-align: left;
  78.         }
  79.     </style>
  80. </head>
  81. <body>
  82. <div id="users-contain" class="ui-widget">
  83.     <h3>Летови: </h3>
  84.     <table id="users" class="ui-widget ui-widget-content">
  85.         <thead>
  86.         <tr class="ui-widget-header ">
  87.             <th>Шифра</th>
  88.             <th>Авиопревозник</th>
  89.             <th>До</th>
  90.             <th>Класа</th>
  91.         </tr>
  92.         </thead>
  93.  
  94.         <tbody id="podatoci">
  95.         <tr>
  96.             <td>12331</td>
  97.             <td>Wizz Air</td>
  98.             <td>London</td>
  99.             <td>Бизнис</td>
  100.         </tr>
  101.         </tbody>
  102.     </table>
  103. </div>
  104. <form id="dialog" title="Create new flight">
  105.  
  106.     <p>Сите полиња се задолжителни</p>
  107.  
  108.     <label>Шифра</label>
  109.     <br/>
  110.     <input id="sifra">
  111.     <br/>
  112.     <br/>
  113.     <label>Авиопревозник</label>
  114.     <br/>
  115.     <input id="prevoznik">
  116.     <br/>
  117.     <br/>
  118.     <label>До</label>
  119.     <br/>
  120.     <input id="do">
  121.     <br/>
  122.     <br/>
  123.     <select id="selekt">
  124.         <option>Бизнис</option>
  125.         <option>Економска</option>
  126.         <option>Прва</option>
  127.     </select>
  128. </form>
  129. <button id="buton" >Додади нова ставка</button>
  130. </body>
  131. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement