Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>lab4zadaca3</title>
- <script src="jquery.js"></script>
- <script src="jquery-ui.js"></script>
- <link rel="stylesheet" href="jquery-ui.css">
- <script>
- $(document).ready(function() {
- $( "#dialog" ).dialog({
- modal: true,
- autoOpen: false,
- resizable: false,
- height:270,
- buttons: {
- Додади: function() {
- validateForm();
- $( this ).dialog( "close" );
- },
- Откажи: function() {
- $( this ).dialog( "close" );
- }
- }
- });
- function validateForm() {
- var $sifra = document.forms["dialog"]["sifra"].value;
- var $prevoznik = document.forms["dialog"]["prevoznik"].value;
- var $do = document.forms["dialog"]["do"].value;
- if ($sifra=="" || $prevoznik == "" || $do == "") {
- window.alert("Сите полиња се задолжителни");
- } else {
- var flag = true;
- for (var i = 0 ; i < $sifra.length ; i++) {
- if ($sifra.charAt(i) < '0' || $sifra.charAt(i) > '9') {
- flag = false;
- break;
- }
- }
- if (flag == true) {
- var $selectedValue = $("#selekt option:selected").text();
- $( "tbody" ).append( "<tr>" +
- "<td>" + $sifra + "</td>" +
- "<td>" + $prevoznik + "</td>" +
- "<td>" + $do + "</td>" +
- "<td>" + $selectedValue + "</td>" +
- "</tr>" );
- } else {
- window.alert("Шифрата мора да е составена само од цифри");
- }
- }
- document.getElementById("dialog").reset();
- }
- $("#buton").click(function() {
- $("#dialog").dialog("open");
- });
- });
- </script>
- <style >
- body {
- font-size: 10px;
- }
- #users-contain table {
- border-collapse: collapse;
- width: 20px;
- }
- #users-contain table td,#users-contain table th {
- border: 1px solid #eee;
- padding: 6px 10px;
- text-align: left;
- }
- </style>
- </head>
- <body>
- <div id="users-contain" class="ui-widget">
- <h3>Летови: </h3>
- <table id="users" class="ui-widget ui-widget-content">
- <thead>
- <tr class="ui-widget-header ">
- <th>Шифра</th>
- <th>Авиопревозник</th>
- <th>До</th>
- <th>Класа</th>
- </tr>
- </thead>
- <tbody id="podatoci">
- <tr>
- <td>12331</td>
- <td>Wizz Air</td>
- <td>London</td>
- <td>Бизнис</td>
- </tr>
- </tbody>
- </table>
- </div>
- <form id="dialog" title="Create new flight">
- <p>Сите полиња се задолжителни</p>
- <label>Шифра</label>
- <br/>
- <input id="sifra">
- <br/>
- <br/>
- <label>Авиопревозник</label>
- <br/>
- <input id="prevoznik">
- <br/>
- <br/>
- <label>До</label>
- <br/>
- <input id="do">
- <br/>
- <br/>
- <select id="selekt">
- <option>Бизнис</option>
- <option>Економска</option>
- <option>Прва</option>
- </select>
- </form>
- <button id="buton" >Додади нова ставка</button>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement