Guest User

daj

a guest
Sep 28th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //LISTA I1
  2.  
  3. <!DOCTYPE html>
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Zadatak 02</title>
  7. </head>
  8. <body>
  9. <h1>SUPIT - oznaka <i>&lt;table&gt;</i></h1>
  10. <h3>Elementi oznake &lt;table&gt;:</h3>
  11. <ol>
  12. <li>Element <b>&lt;caption&gt;</b></li>
  13. <li>
  14. Elementi za grupiranje redaka:
  15. <ol type="i" start="1">
  16. <li><b>&lt;thead&gt;</b></li>
  17. <li><b>&lt;tfoot&gt;</b></li>
  18. <li><b>&lt;tbody&gt;</b></li>
  19. </ol>
  20. </li>
  21. <li>
  22. Element za definiranje retka <b>&lt;tr&gt;</b>
  23. <ul>
  24. <li><b>&lt;th&gt;</b> - naslovna ćelija</li>
  25. <li><b>&lt;td&gt;</b> - ćelija</li>
  26. </ul>
  27. </li>
  28. </ol>
  29. </body>
  30. </html>
  31.  
  32.  
  33. //TABLICA I2
  34. <!DOCTYPE html>
  35. <html>
  36. <head>
  37. <title>Zadatak 12</title>
  38. <meta charset="utf-8" />
  39. </head>
  40. <body>
  41. <table border="1" cellspacing="0" cellpadding="3px" align="center" rules="groups" width="800px">
  42. <caption>Popis zaposlenika</caption>
  43. <colgroup>
  44. <col width="80px" />
  45. <col width="80px" />
  46. </colgroup>
  47. <colgroup>
  48. <col width="160px" />
  49. <col width="160px" />
  50. </colgroup>
  51. <colgroup>
  52. <col width="160px" />
  53. <col width="160px" />
  54. </colgroup>
  55. <thead>
  56. <tr>
  57. <th rowspan="2" align="left">Ime</th>
  58. <th rowspan="2" align="left">Prezime</th>
  59. <th colspan="2" bgcolor="yellow">Privatni podaci</th>
  60. <th colspan="2" bgcolor="yellow">Poslovni podaci</th>
  61. </tr>
  62. <tr align="left">
  63. <th>Adresa</th>
  64. <th>E-mail</th>
  65. <th>Adresa</th>
  66. <th>E-mail</th>
  67. </tr>
  68. </thead>
  69. <tbody>
  70. <tr>
  71. <td>Marko</td>
  72. <td>Marić</td>
  73. <td>Ilica 1</td>
  74. <td><a href="mailto:marko@mail.com">marko@mail.com</a></td>
  75. <td>Frankopanska 101</td>
  76. <td><a href="mailto:mm@mail.com">mm@mail.com</a></td>
  77. </tr>
  78. <tr>
  79. <td>Maja</td>
  80. <td>Majić</td>
  81. <td>Mesićeva 22</td>
  82. <td><a href="mailto:maja.majic@mail.hr">maja.majic@mail.hr</a></td>
  83. <td>Gajdekova 72a</td>
  84. <td><a href="mailto:majic.maja@mojposao.hr">majic.maja@mojposao.hr</a></td>
  85. </tr>
  86. <tr>
  87. <td>Pero</td>
  88. <td>Peroković</td>
  89. <td>Kriška 18</td>
  90. <td><a href="mailto:m.perokovic@email.hr">m.perokovic@email.hr</a></td>
  91. <td>Vlaška 81</td>
  92. <td><a href="mailto:pp@firma.com.hr">pp@firma.com.hr</a></td>
  93. </tr>
  94. <tr>
  95. <td>Ana</td>
  96. <td>Anić</td>
  97. <td>Teslina 14</td>
  98. <td><a href="mailto:ana@mail.org">ana@mail.org</a></td>
  99. <td>Petrovaradinska bb</td>
  100. <td><a href="mailto:ana@kompanija.hr">ana@kompanija.hr</a></td>
  101. </tr>
  102. </tbody>
  103. </table>
  104. </body>
  105. </html>
  106.  
  107.  
  108. //FORMULAR I1
  109.  
  110.  
  111. <html>
  112. <head>
  113. <title>Zadatak 3</title>
  114. </head>
  115. <body>
  116. <form action="#" method="post" >
  117.  
  118. <fieldset>
  119. <legend align="left">Ime i prezime</legend>
  120.  
  121. <table>
  122. <tr>
  123. <td><label for="ime">Ime:</label></td>
  124. <td><input type="text" id="ime" name="txtIme" /></td>
  125. </tr>
  126. <tr>
  127. <td><label for="prezime">Prezime:</label></td>
  128. <td><input type="text" id="prezime" name="txtPrezime" /></td>
  129. </tr>
  130. </table>
  131. </fieldset>
  132. <br/>
  133. <fieldset>
  134. <legend align="left" >Email koji æe Vam ujedno biti i korisnièko ime</legend>
  135.  
  136. <table>
  137. <tr>
  138. <td><label for="email1">Email:</label></td>
  139. <td><input type="email" id="email1" name="txtEmail"/></td>
  140. </tr>
  141. <tr>
  142. <td><label for="email2">Ponovite email:</label></td>
  143. <td><input type="text" id="email2" name="txtEmail"/></td>
  144. </tr>
  145. </table>
  146. </fieldset>
  147. <br/>
  148. <fieldset>
  149. <legend align="left" >Željena lozinka</legend>
  150.  
  151. <table>
  152. <tr>
  153. <td><label for="pw1">Lozinka:</label></td>
  154. <td><input type="password" id="pw1" name="txtLozinka" /></td>
  155. </tr>
  156. <tr>
  157. <td><label for="pw2">Ponovite lozinku:</label></td>
  158. <td><input type="password" id="pw2" name="txtLozinka"/></td>
  159. </tr>
  160. </table>
  161. </fieldset>
  162. <br/>
  163. <fieldset>
  164. <legend>Spol</legend>
  165.  
  166. <table>
  167. <tr>
  168. <td>
  169. <label for="z">Ženski</label>
  170. <input type="radio" id="z" name="rdbSpol" value="ž" checked="checked" />
  171. <label for="m">Muški</label>
  172. <input type="radio" id="m" name="rdbSpol" value="m" />
  173. </td>
  174. </tr>
  175. </table>
  176. </fieldset>
  177.  
  178. <br/>
  179. Država: <select name="mnuDržava" >
  180. <optgroup label="Europa">
  181. <option value="hrv" selected>Hrvatska</option>
  182. <option value="nje">Njemaèka</option>
  183. </optgroup>
  184. <optgroup label="Azija">
  185. <option value="jpn">Japan</option>
  186. </optgroup>
  187. </select>
  188.  
  189. <br/><br/>
  190.  
  191. <fieldset>
  192. <legend>Vrsta pretplate</legend>
  193. <label for="1g">Jednogodišnja pretplata</label>
  194. <input type="radio" id="1g" name="rdbPretplata" value="da1g" checked />
  195. <input type="radio" id="2g" name="rdbPretplata" value="da2g" />
  196. <label for="2g">Dvogodišnja pretplata</label>&nbsp;&nbsp;&nbsp;
  197. <br/>
  198. </fieldset>
  199. <br/>
  200. Komentar:
  201. <br />
  202. <textarea name="txtKomentar" rows="3" cols="80"></textarea>
  203. <br/>
  204. <br/>
  205. Naznaèite podruèja interesa:
  206. <br/>
  207. <select name="mnuInteresi" multiple>
  208. <option value="sport">Sport</option>
  209. <option value="glazba">Glazba</option>
  210. <option value="politika">Politika</option>
  211. <option value="književnost">Književnost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
  212. </select>
  213. <br/>
  214. <br/>
  215. <input type="checkbox" id="prihv" name="chkPrihvacam" value="prihvacam">
  216. <label for="prihv">Prihvaæam uvjete i potvrðujem da su upisani podaci istiniti...</label>
  217. <br/>
  218. <br/>
  219. <input type="submit" value="Prihvati" />
  220. <input type="reset" value="Resetiraj obrazac" />
  221. </form>
  222. </body>
  223. </html>
  224.  
  225.  
  226. //22
  227. body {
  228. font-family:'Segoe UI';
  229. margin-top:60px;
  230. }
  231. div{
  232. box-sizing:border-box;
  233. margin:auto;
  234. width:400px;
  235. height:400px;
  236. box-shadow:0 0 20px #ccc;
  237. padding:10px;
  238. }
  239. h1{
  240. font-weight:100;
  241. margin-top:10px;
  242. text-align:center;
  243. }
  244. img{
  245. float:left;
  246. padding-bottom:9px;
  247. padding-left:5px;
  248. }
  249. p{
  250. text-align:justify;
  251. font-size:0.9em;
  252. }
  253. a{
  254. text-decoration:none;
  255. display:block;
  256. line-height:40px;
  257. }
  258.  
  259.  
  260. //23
  261.  
  262. body {
  263. font-family:'Segoe UI';
  264. }
  265. #main{
  266. width:800px;
  267. margin:auto;
  268. }
  269. #header h1 {
  270. font-weight: 400;
  271. text-align: center;
  272. text-transform: uppercase;
  273. border-bottom: 1px solid #ccc;
  274. line-height: 50px;
  275. }
  276.  
  277. #nav ul{
  278. list-style:none;
  279.  
  280. }
  281. #nav ul li{
  282. box-sizing:border-box;
  283. display:inline-block;
  284. border-radius:50%;
  285. width:100px;
  286. height:100px;
  287. margin:auto;
  288. overflow:hidden;
  289. border:1px solid #ccc;
  290. margin:10px 20px 20px;
  291. }
  292. #nav a{
  293. color:black;
  294. text-decoration:none;
  295. display:block;
  296. line-height:92px;
  297. text-align:center;
  298. }
  299. #nav ul li:hover{
  300. box-shadow:0 0 20px #ccc;
  301. animation-duration:2s;
  302. Transform:rotate(360deg);
  303. transition-duration:0.25s;
  304. }
  305. #content{
  306. margin:0;
  307. margin-left:70px;
  308. }
  309. #stupac{
  310. border:1px solid #ccc;
  311. box-sizing:border-box;
  312. width:200px;
  313. height:200px;
  314. float:left;
  315. padding:10px;
  316. margin:10px;
  317. }
  318. h2{
  319. font-weight:400;
  320. }
  321. p{
  322. font-size:0.9em;
  323. text-align:justify;
  324. }
  325.  
  326. //31
  327.  
  328. <!DOCTYPE html>
  329. <html>
  330. <head>
  331. <title>Proba</title>
  332. <script src="jquery-1.11.3.min.js"></script>
  333. <script>
  334. $(document).ready(function(){
  335. $('#slider').on('change', function(){
  336. console.log($('#slider').val());
  337. range = $(this).val();
  338. kvadrat(range);
  339. });
  340.  
  341. });
  342.  
  343. function kvadrat (size){
  344. $('#box').css('height', size);
  345. $('#box').css('width', size);
  346. }
  347. </script>
  348. </head>
  349. <body>
  350.  
  351. <input type="range" id="slider">
  352.  
  353. <div id="container">
  354. <div id="box" style="border:1px solid #000;"></div>
  355. </div>
  356.  
  357. <body>
  358. </html>
  359.  
  360.  
  361. //32
  362.  
  363. var ime, prezime, godine;
  364. var poljeIme = [];
  365. var poljePrezime = [];
  366. var poljeGodine = [];
  367. var ispis = "";
  368. window.onload = function () {
  369. do {
  370. ime = prompt("Unesite ime:");
  371. while (ime.length == 0) {
  372. ime = prompt("Morate unijeti ime, polje za unos ne smije biti prazno:");
  373. }
  374. prezime = prompt("Unesite prezime:");
  375. while (prezime.length == 0) {
  376. prezime = prompt("Morate unijeti prezime, polje za unos ne smije biti prazno:");
  377. }
  378. godine = prompt("Unesite godine:");
  379. while (godine.length == 0) {
  380. godine = prompt("Morate unijeti godine, polje za unos ne smije biti prazno:");
  381. }
  382. poljeIme.push(ime);
  383. poljePrezime.push(prezime);
  384. poljeGodine.push(godine);
  385. } while (confirm("Ponovi?"));
  386.  
  387. Ispis();
  388. Najdulje();
  389. }
  390.  
  391. function Ispis() {
  392. for (var i = 0; i < poljeIme.length; i++) {
  393. ispis += "IME:" + poljeIme[i] + "\n";
  394. ispis += "PREZIME:" + poljePrezime[i] + "\n";
  395. ispis += "GODINE:" + poljeGodine[i] + "\n";
  396. ispis += "------------------\n";
  397. }
  398. alert(ispis);
  399. }
  400.  
  401. function Najdulje() {
  402. var najdulje = poljePrezime[0];
  403. var ispisNajduljeg = "";
  404. for (var i = 0; i < poljePrezime.length; i++) {
  405. if (poljePrezime[i].length > najdulje.length) {
  406. najdulje = poljePrezime[i];
  407. }
  408. }
  409. for (var i = 0; i < poljePrezime.length; i++) {
  410. if (poljePrezime[i] == najdulje) {
  411. ispisNajduljeg += "ISPIS STUDENTA S NADULJIM PREZIMENOM\n";
  412. ispisNajduljeg += "IME:" + poljeIme[i] + "\n";
  413. ispisNajduljeg += "PREZIME:" + poljePrezime[i] + "\n";
  414. ispisNajduljeg += "GODINE:" + poljeGodine[i] + "\n";
  415. }
  416. }
  417. alert(ispisNajduljeg);
  418. }
  419.  
  420.  
  421. //33 HTML
  422.  
  423. <!DOCTYPE html>
  424. <html>
  425. <head>
  426. <title>Zadatak34</title>
  427. <script src="jquery-1.11.3.min.js"></script>
  428. <script src="Zadatak34.js"></script>
  429. <meta charset="utf-8" />
  430. </head>
  431. <body>
  432. <div id="main">
  433.  
  434. <div class="floatLeft L">
  435. <label for="ime">
  436. Ime:
  437. </label>
  438. <input type="text" id="ime" value="" />
  439.  
  440. <label for="prezime">
  441. Prezime:
  442. </label>
  443. <input type="text" id="prezime" value="" />
  444.  
  445. <label for="email">
  446. Email:
  447. </label>
  448. <input type="email" id="email" value="" />
  449.  
  450. <label for="telefon">
  451. Telefon:
  452. </label>
  453. <input type="tel" id="telefon" value="" />
  454. <input type="button" value="Dodaj" id="btnDodaj" />
  455. </div>
  456. <div class="floatLeft R">
  457. <label>Unesene osobe[<span>0</span>]:</label>
  458. <select>
  459. <option>--- odaberi ---</option>
  460. </select>
  461. <ul></ul>
  462. </div>
  463.  
  464. </div>
  465. </body>
  466. </html>
  467.  
  468.  
  469. //JS
  470.  
  471.  
  472. /// <reference path="jquery-1.11.3.min.js" />
  473.  
  474. //var ime, prezime, email, tel, sadrzaj;
  475. //var brojac = 0;
  476. //var selectBrojac = 1;
  477. //var polje_ime = [];
  478. //var polje_prezime = [];
  479. //var polje_email = [];
  480. //var polje_tel = [];
  481.  
  482. //$(document).keypress(function (e) {
  483. // if (e.which == 13) {
  484. // $("#btnDodaj").click();
  485. // }
  486. //});
  487.  
  488. //$(function () {
  489. // $("#ime").focus();
  490. // $("#btnDodaj").click(function () {
  491. // ime = $("#ime").val();
  492. // prezime = $("#prezime").val();
  493. // email = $("#email").val();
  494. // tel = $("#telefon").val();
  495.  
  496. // if (ime == "" || prezime == "" || email == "" || tel == "") {
  497. // alert("Sva polja za unos su obavezna!");
  498. // }
  499.  
  500. // else {
  501.  
  502. // polje_ime.push(ime);
  503. // console.log(polje_ime);
  504. // polje_prezime.push(prezime);
  505. // polje_email.push(email);
  506. // polje_tel.push(tel);
  507. // brojac++;
  508. // $("span").html(brojac);
  509. // reset();
  510. // dodajSelectu(ime, prezime);
  511. // }
  512.  
  513. // });
  514.  
  515. // $("select").change(function () {
  516. // $("ul").html = "";
  517. // var trenutno = $(this).val();
  518. // var li = $(document.createElement("li"));
  519.  
  520. // var iscrtajul = "";
  521. // if (trenutno > 0) {
  522. // iscrtajul += "<li>";
  523. // iscrtajul += polje_ime[trenutno - 1];
  524. // iscrtajul += "</li>"
  525.  
  526. // iscrtajul += "<li>";
  527. // iscrtajul += polje_prezime[trenutno - 1];
  528. // iscrtajul += "</li>"
  529.  
  530. // iscrtajul += "<li>";
  531. // iscrtajul += polje_email[trenutno - 1];
  532. // iscrtajul += "</li>"
  533.  
  534. // iscrtajul += "<li>";
  535. // iscrtajul += polje_tel[trenutno - 1];
  536. // iscrtajul += "</li>";
  537. // } else {
  538.  
  539. // iscrtajul = "";
  540. // }
  541.  
  542.  
  543. // $("ul").html(iscrtajul);
  544.  
  545. // });
  546.  
  547. //})
  548.  
  549.  
  550. //function dodajSelectu(ime, prezime) {
  551. // var opcija = new Option(ime + " " + prezime, selectBrojac);
  552. // $("select").append(opcija);
  553. // selectBrojac++;
  554. //}
  555.  
  556. //function reset() {
  557. // $("#ime").val("");
  558. // $("#prezime").val("");
  559. // $("#email").val("");
  560. // $("#telefon").val("");
  561.  
  562. // $("#ime").focus();
  563. //}
  564.  
  565. //druga verzija, ljepši kod, ali šteka.
  566.  
  567. var ime, prezime, email, tel, sadrzaj;
  568. var brojac = 0;
  569. var selectBrojac = 1;
  570. var polje_ime = [];
  571. var polje_prezime = [];
  572. var polje_email = [];
  573. var polje_tel = [];
  574.  
  575. $(document).keypress(function (e) {
  576. if (e.which == 13) {
  577. $("#btnDodaj").click();
  578. }
  579. });
  580.  
  581. $(function () {
  582. $("#ime").focus();
  583. $("#btnDodaj").click(function () {
  584. ime = $("#ime").val();
  585. prezime = $("#prezime").val();
  586. email = $("#email").val();
  587. tel = $("#telefon").val();
  588.  
  589. if (ime == "" || prezime == "" || email == "" || tel == "") {
  590. alert("Sva polja za unos su obavezna!");
  591. }
  592.  
  593. else {
  594.  
  595. polje_ime.push(ime);
  596. polje_prezime.push(prezime);
  597. polje_email.push(email);
  598. polje_tel.push(tel);
  599. brojac++;
  600. $("span").html(brojac);
  601. reset();
  602. dodajSelectu(ime, prezime);
  603. }
  604. });
  605.  
  606. $("select").change(function () {
  607. $("ul").html("");
  608.  
  609. var trenutno = $(this).val();
  610.  
  611. if (trenutno > 0) {
  612.  
  613. console.log(trenutno);
  614. var li = $(document.createElement("li"));
  615. var sadrzaj = $(document.createTextNode(polje_ime[trenutno - 1] + " " +
  616. polje_prezime[trenutno - 1] + " " + polje_email[trenutno - 1] + " " + polje_tel[trenutno - 1]));
  617. li.append(sadrzaj);
  618. $("ul").append(li);
  619.  
  620. }
  621.  
  622. })
  623.  
  624. })
  625.  
  626.  
  627. function dodajSelectu(ime, prezime) {
  628. var osoba = $(document.createTextNode(ime + " " + prezime));
  629. var option = $(document.createElement("option"));
  630. option.val(selectBrojac);
  631. option.append(osoba);
  632. $("select").append(option);
  633. console.log($("option").val());
  634. selectBrojac++;
  635. }
  636.  
  637. function reset() {
  638. $("#ime").val("");
  639. $("#prezime").val("");
  640. $("#email").val("");
  641. $("#telefon").val("");
  642.  
  643. $("#ime").focus();
  644. }
  645.  
  646.  
  647. //Zadatak41 - U XMLSchema se radi sve
  648.  
  649.  
  650. <?xml version="1.0" encoding="utf-8"?>
  651. <xs:schema id="Zadatak41"
  652. targetNamespace="http://tempuri.org/Zadatak41.xsd"
  653. elementFormDefault="qualified"
  654. xmlns="http://tempuri.org/Zadatak41.xsd"
  655. xmlns:mstns="http://tempuri.org/Zadatak41.xsd"
  656. xmlns:xs="http://www.w3.org/2001/XMLSchema">
  657. <xs:element name="podaci">
  658. <xs:complexType>
  659. <xs:sequence>
  660. <xs:element name="osoba" maxOccurs="50">
  661. <xs:complexType>
  662. <xs:sequence>
  663. <xs:element name="ime" type="xs:string"></xs:element>
  664. <xs:element name="prezime" type="xs:string"></xs:element>
  665. <xs:element name="email" type="mail"></xs:element>
  666. <xs:element name="telefon">
  667. <xs:complexType>
  668. <xs:attribute name="fiksni" use="optional" type="tel"></xs:attribute>
  669. <xs:attribute name="gsm" use="required" type="mob"></xs:attribute>
  670. </xs:complexType>
  671. </xs:element>
  672. </xs:sequence>
  673. <xs:attribute name="oib" type="indet" use="required"></xs:attribute>
  674. </xs:complexType>
  675. </xs:element>
  676. </xs:sequence>
  677. </xs:complexType>
  678. </xs:element>
  679. <xs:element name="tel">
  680. <xs:simpleType>
  681. <xs:restriction base="xs:string">
  682. <xs:pattern value="[0-9]{4}\.[0-9]{3}"></xs:pattern>
  683. </xs:restriction>
  684. </xs:simpleType>
  685. </xs:element>
  686. <xs:element name="mob">
  687. <xs:simpleType>
  688. <xs:restriction base="xs:string">
  689. <xs:pattern value="09[1|2|8]\.[0-9]{4}\.[0-9]{3}"></xs:pattern>
  690. </xs:restriction>
  691. </xs:simpleType>
  692. </xs:element>
  693. <xs:element name="oib">
  694. <xs:simpleType>
  695. <xs:restriction base="xs:string">
  696. <xs:pattern value="[0-9]{11}"></xs:pattern>
  697. </xs:restriction>
  698. </xs:simpleType>
  699. </xs:element>
  700. <xs:element name="mail">
  701. <xs:simpleType>
  702. <xs:restriction base="xs:string">
  703. <xs:pattern value="[a-z]+@[a-z]+\.[a-z]{2,4}"></xs:pattern>
  704. </xs:restriction>
  705. </xs:simpleType>
  706. </xs:element>
  707. </xs:schema>
  708.  
  709.  
  710.  
  711. //Zadatak42 - sve u JSu radim, samo u HTML referenca
  712. window.onload = ucitajXML;
  713. var imeDatoteke = 'Zadatak42.xml';
  714. function ucitajXML() {
  715. xmlhr = new XMLHttpRequest();
  716. xmlhr.open('GET', imeDatoteke, true);
  717. xmlhr.onreadystatechange = onChange;
  718. xmlhr.send();
  719. }
  720. function onChange() {
  721. if (xmlhr.readyState == 4) {
  722. podaci();
  723. }
  724. }
  725. function podaci() {
  726. var ispis = "";
  727. xmlDom = xmlhr.responseXML;
  728. dom = xmlDom.documentElement;
  729. cvorOsoba = dom.getElementsByTagName('osoba');
  730. for (var i = 0; i < cvorOsoba.length; i++) {
  731. var osoba = dom.getElementsByTagName('osoba')[i];
  732. var ime = osoba.getElementsByTagName('ime')[0].firstChild.nodeValue;
  733. var prezime = osoba.getElementsByTagName('prezime')[0].firstChild.nodeValue;
  734. var oib = osoba.attributes[0].value;
  735. ispis += ime + " " + prezime + "[" + "oib:" + oib + "]\n";
  736. }
  737. console.log(ispis);
  738. }
  739.  
  740.  
  741.  
  742. //Zadatak43 - U JSu radim sve, samo referenca u HTMLu
  743. /// <reference path="jquery-1.11.3.min.js" />
  744. var xmlhr, xmlDom, cvorOsoba;
  745. window.onload = function () {
  746. ucitajXML();
  747. }
  748. function ucitajXML() {
  749. xmlhr = new XMLHttpRequest();
  750. xmlhr.open("GET", "XMLFile.xml", true);
  751. xmlhr.onreadystatechange = function () {
  752. if (xmlhr.readyState == 4) {
  753. prikazPodataka();
  754. }
  755. }
  756. xmlhr.send();
  757. lista = document.getElementsByTagName("select")[0];
  758. lista.onchange = ispis;
  759. $("#btnDodaj").click(dodajOsobu);
  760. $("#btnUredi").click(urediOsobu);
  761. $("#btnObrisi").click(obrisiOsobu);
  762. }
  763. function prikazPodataka() {
  764. xmlDom = xmlhr.responseXML;
  765. cvorOsoba = xmlDom.getElementsByTagName("osoba");
  766. for (var i = 0; i < cvorOsoba.length; i++) {
  767. var oib = cvorOsoba[i].attributes[0].value;
  768. var ime = cvorOsoba[i].getElementsByTagName("ime")[0].firstChild.nodeValue;
  769. var prezime = cvorOsoba[i].getElementsByTagName("prezime")[0].firstChild.nodeValue;
  770. var select = document.getElementsByTagName("select")[0];
  771. var imeIprezime = ime + " " + prezime;
  772. select.appendChild(ubaciSelectu(imeIprezime, oib));
  773. }
  774. }
  775. function ubaciSelectu(name, data) {
  776. var option = document.createElement("option");
  777. var tekst = document.createTextNode(name);
  778. option.setAttribute("value", data);
  779. option.appendChild(tekst);
  780. return option;
  781. }
  782. function ispis() {
  783. var index = lista.selectedIndex;
  784. var ime = cvorOsoba[index].getElementsByTagName("ime")[0].firstChild.nodeValue;
  785. var prezime = cvorOsoba[index].getElementsByTagName("prezime")[0].firstChild.nodeValue;
  786. var oib = cvorOsoba[index].attributes[0].value;
  787. document.getElementById("txtIme").value = ime;
  788. document.getElementById("txtPrezime").value = prezime;
  789. document.getElementById("txtOIB").value = oib;
  790. }
  791. function dodajOsobu() {
  792. var imeDodaj = $("#txtIme").val();
  793. var prezimeDodaj = $("#txtPrezime").val();
  794. var oibDodaj = $("#txtOIB").val();
  795. if (imeDodaj == "" || prezimeDodaj == "" || oibDodaj == "") {
  796. alert("Sva polja su obavezna!!!");
  797. }
  798. var cvorOsoba = xmlDom.createElement("osoba");
  799. cvorOsoba.setAttribute("oib", oibDodaj);
  800. var cvorIme = xmlDom.createElement("ime");
  801. cvorIme.appendChild(xmlDom.createTextNode(imeDodaj));
  802. var cvorPrezime = xmlDom.createElement("prezime");
  803. cvorPrezime.appendChild(xmlDom.createTextNode(prezimeDodaj));
  804. cvorOsoba.appendChild(cvorIme);
  805. cvorOsoba.appendChild(cvorPrezime);
  806. xmlDom.documentElement.appendChild(cvorOsoba);
  807. $("select").empty();
  808. reset();
  809. }
  810. function urediOsobu() {
  811. var selectedOption = document.getElementsByTagName("select")[0];
  812. var index = selectedOption.selectedIndex;
  813. cvorOsoba[index].getElementsByTagName("ime")[0].firstChild.nodeValue = document.getElementById("txtIme").value;
  814. cvorOsoba[index].getElementsByTagName("prezime")[0].firstChild.nodeValue = document.getElementById("txtPrezime").value;
  815. cvorOsoba[index].attributes[0].value = document.getElementById("txtOIB").value;
  816. reset();
  817. }
  818. function obrisiOsobu() {
  819. var index = lista.selectedIndex;
  820. if (index != -1) {
  821. xmlDom.documentElement.removeChild(cvorOsoba[index]);
  822. reset();
  823. }
  824. }
  825. function reset() {
  826. $("#txtIme, #txtPrezime, #txtOIB").val("");
  827. $("#txtIme").focus();
  828. $("select").empty();
  829. prikazPodataka();
  830. }
  831.  
  832.  
  833. //31
  834.  
  835. <!DOCTYPE html>
  836. <html>
  837. <head>
  838. <title>Proba</title>
  839. <script src="jquery-1.11.3.min.js"></script>
  840. <script>
  841. $(document).ready(function(){
  842. $('#slider').on('change', function(){
  843. console.log($('#slider').val());
  844. range = $(this).val();
  845. kvadrat(range);
  846. });
  847.  
  848. });
  849.  
  850. function kvadrat (size){
  851. $('#box').css('height', size);
  852. $('#box').css('width', size);
  853. }
  854. </script>
  855. </head>
  856. <body>
  857.  
  858. <input type="range" id="slider">
  859.  
  860. <div id="container">
  861. <div id="box" style="border:1px solid #000;"></div>
  862. </div>
  863.  
  864. <body>
  865. </html>
  866.  
  867. //32
  868.  
  869. var ime, prezime, godine;
  870. var poljeIme = [];
  871. var poljePrezime = [];
  872. var poljeGodine = [];
  873. var ispis = "";
  874. window.onload = function () {
  875. do {
  876. ime = prompt("Unesite ime:");
  877. while (ime.length == 0) {
  878. ime = prompt("Morate unijeti ime, polje za unos ne smije biti prazno:");
  879. }
  880. prezime = prompt("Unesite prezime:");
  881. while (prezime.length == 0) {
  882. prezime = prompt("Morate unijeti prezime, polje za unos ne smije biti prazno:");
  883. }
  884. godine = prompt("Unesite godine:");
  885. while (godine.length == 0) {
  886. godine = prompt("Morate unijeti godine, polje za unos ne smije biti prazno:");
  887. }
  888. poljeIme.push(ime);
  889. poljePrezime.push(prezime);
  890. poljeGodine.push(godine);
  891. } while (confirm("Ponovi?"));
  892.  
  893. Ispis();
  894. Najdulje();
  895. }
  896.  
  897. function Ispis() {
  898. for (var i = 0; i < poljeIme.length; i++) {
  899. ispis += "IME:" + poljeIme[i] + "\n";
  900. ispis += "PREZIME:" + poljePrezime[i] + "\n";
  901. ispis += "GODINE:" + poljeGodine[i] + "\n";
  902. ispis += "------------------\n";
  903. }
  904. alert(ispis);
  905. }
  906.  
  907. function Najdulje() {
  908. var najdulje = poljePrezime[0];
  909. var ispisNajduljeg = "";
  910. for (var i = 0; i < poljePrezime.length; i++) {
  911. if (poljePrezime[i].length > najdulje.length) {
  912. najdulje = poljePrezime[i];
  913. }
  914. }
  915. for (var i = 0; i < poljePrezime.length; i++) {
  916. if (poljePrezime[i] == najdulje) {
  917. ispisNajduljeg += "ISPIS STUDENTA S NADULJIM PREZIMENOM\n";
  918. ispisNajduljeg += "IME:" + poljeIme[i] + "\n";
  919. ispisNajduljeg += "PREZIME:" + poljePrezime[i] + "\n";
  920. ispisNajduljeg += "GODINE:" + poljeGodine[i] + "\n";
  921. }
  922. }
  923. alert(ispisNajduljeg);
  924. }
  925.  
  926. //33
  927.  
  928. /// <reference path="jquery-1.11.3.min.js" />
  929.  
  930.  
  931.  
  932. var poljeIme = [];
  933. var poljePrezime = [];
  934. var poljeTel = [];
  935. var poljeMail = [];
  936.  
  937. var optionBrojac = 1;
  938. var brojac=0;
  939.  
  940. $(function () {
  941. $("#btnDodaj").click(function () {
  942. ime = $("#ime").val();
  943. prezime = $("#prezime").val();
  944. mail = $("#email").val();
  945. telefon = $("#telefon").val();
  946.  
  947. if (ime == "" || prezime == "" || mail == "" || telefon == "") {
  948. alert("Sva polja za unos su obavezna.");
  949. }
  950. else {
  951. poljeIme.push(ime);
  952. poljePrezime.push(prezime);
  953. poljeTel.push(telefon);
  954. poljeMail.push(mail);
  955. brojac++;
  956. $("span").html(brojac);
  957. dodajUSelect(ime, prezime);
  958. reset();
  959. }
  960.  
  961.  
  962. });
  963.  
  964. $("select").change(function () {
  965. $("ul").html("");
  966. var pozicija = $(this).val();
  967. if (pozicija > 0) {
  968. var li_mail = $(document.createElement("li"));
  969. var tekstMail = $(document.createTextNode(poljeMail[pozicija - 1]));
  970. li_mail.append(tekstMail);
  971. $("ul").append(li_mail);
  972. var li_tel = $(document.createElement("li"));
  973. var tekstTel = $(document.createTextNode(poljeTel[pozicija - 1]));
  974. $("ul").append(tekstTel);
  975. }
  976. else {
  977. $("ul").html("");
  978. }
  979.  
  980. });
  981. });
  982.  
  983. function dodajUSelect(ime, prezime) {
  984. var tekst = $(document.createTextNode(ime + " " + prezime));
  985. var option = $(document.createElement("option"));
  986. option.val(optionBrojac);
  987. option.append(tekst);
  988. $("select").append(option);
  989. optionBrojac++;
  990. }
  991.  
  992. function reset() {
  993. $("#ime").val("").focus();
  994. $("#prezime").val("");
  995. $("#email").val("");
  996. $("#telefon").val("");
  997.  
  998. }
  999.  
  1000. $(document).keypress(function (e) {
  1001. if (e.which==13) {
  1002. $("#btnDodaj").click();
  1003. }
  1004. })
  1005.  
  1006. //41
  1007. XML FILE
  1008.  
  1009. <?xml version="1.0" encoding="utf-8"?>
  1010. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  1011.  
  1012.  
  1013. <xsl:template match="/">
  1014. <html>
  1015. <head>
  1016. <title>Zadatak01</title>
  1017. <style type="text/css">
  1018. table{
  1019. margin:auto;
  1020. border:1px solid #ccc;
  1021. margin-bottom:10px;
  1022. }
  1023. </style>
  1024. </head>
  1025. <body>
  1026. <xsl:for-each select="podaci/kolegij">
  1027. <xsl:sort data-type="text" order="ascending" select="naziv"/>
  1028. <table>
  1029. <tr>
  1030. <td>
  1031. <h3>
  1032. <xsl:value-of select="naziv"/>
  1033. </h3>
  1034. </td>
  1035. </tr>
  1036. <tr>
  1037. <td>
  1038. Nastavnik:
  1039. <a>
  1040. <xsl:attribute name="href">
  1041. <xsl:value-of select="nastavnik/@email"/>
  1042. </xsl:attribute>
  1043. <xsl:value-of select="nastavnik/@email"/>
  1044. </a>
  1045.  
  1046. </td>
  1047. </tr>
  1048. </table>
  1049. </xsl:for-each>
  1050. </body>
  1051. </html>
  1052. </xsl:template>
  1053. </xsl:stylesheet>
  1054.  
  1055. //ILI (OVO SU 2 RAZLICITA RJESENJA KOJA SAM NASAO)
  1056.  
  1057. JAVASCRIPT FILE
  1058. /*REFERENCE SU SJEBANE I NEMREM DOBIT JQUERY, TAKO DA FUNKCIJA
  1059. $().empty(); -> NE RADI ZBOG TOGA JER NEMREM DOBIT JQUERY,
  1060.  
  1061. NISAM PAMETAN KAJ RADIT NA ISPITU
  1062. */
  1063.  
  1064. window.onload = ucitajXML;
  1065.  
  1066. var imeDatoteke = 'Zadatak41.xml';
  1067.  
  1068. function ucitajXML() {
  1069. xmlhr = new XMLHttpRequest();
  1070. xmlhr.open('GET', imeDatoteke, true);
  1071. xmlhr.onreadystatechange = onChange;
  1072. xmlhr.send();
  1073.  
  1074.  
  1075. button1 = document.getElementsByTagName('input')[0];
  1076. button1.onclick = prviGumb;
  1077.  
  1078. button2 = document.getElementsByTagName('input')[1];
  1079. button2.onclick = drugiGumb;
  1080.  
  1081. button3 = document.getElementsByTagName('input')[2];
  1082. button3.onclick = treciGumb;
  1083. }
  1084.  
  1085. function onChange() {
  1086. if (xmlhr.readyState == 4) {
  1087. podaci();
  1088. }
  1089. }
  1090.  
  1091. function podaci() {
  1092.  
  1093. xmlDom = xmlhr.responseXML;
  1094. cvorKolegij = xmlDom.getElementsByTagName('kolegij');
  1095.  
  1096. }
  1097.  
  1098. function prviGumb() {
  1099. reset();
  1100. //alert('prvi gumb');
  1101. var naziv = cvorKolegij[0].getElementsByTagName('naziv')[0].firstChild.nodeValue;
  1102.  
  1103. button1.setAttribute('value', naziv);
  1104. var profesor = cvorKolegij[0].getElementsByTagName('nastavnik')[0].firstChild.nodeValue;
  1105. var as1 = cvorKolegij[0].getElementsByTagName('asistent')[0].firstChild.nodeValue;
  1106. var as2 = cvorKolegij[0].getElementsByTagName('asistent')[1].firstChild.nodeValue;
  1107.  
  1108. var ul = document.getElementsByTagName('ul')[0];
  1109.  
  1110. ul.appendChild(dodajLjude(profesor));
  1111. ul.appendChild(dodajLjude(as1));
  1112. ul.appendChild(dodajLjude(as2));
  1113. }
  1114.  
  1115. function drugiGumb() {
  1116. reset();
  1117. var naziv = cvorKolegij[1].getElementsByTagName('naziv')[0].firstChild.nodeValue;
  1118.  
  1119. button2.setAttribute('value', naziv);
  1120. var profesor = cvorKolegij[1].getElementsByTagName('nastavnik')[0].firstChild.nodeValue;
  1121. var as1 = cvorKolegij[1].getElementsByTagName('asistent')[0].firstChild.nodeValue;
  1122.  
  1123. var ul = document.getElementsByTagName('ul')[0];
  1124.  
  1125. ul.appendChild(dodajLjude(profesor));
  1126. ul.appendChild(dodajLjude(as1));
  1127.  
  1128. }
  1129.  
  1130. function treciGumb() {
  1131. reset();
  1132. var naziv = cvorKolegij[1].getElementsByTagName('naziv')[0].firstChild.nodeValue;
  1133.  
  1134. button3.setAttribute('value', naziv);
  1135. var profesor = cvorKolegij[1].getElementsByTagName('nastavnik')[0].firstChild.nodeValue;
  1136. var as1 = cvorKolegij[1].getElementsByTagName('asistent')[0].firstChild.nodeValue;
  1137.  
  1138. var ul = document.getElementsByTagName('ul')[0];
  1139.  
  1140. ul.appendChild(dodajLjude(profesor));
  1141. ul.appendChild(dodajLjude(as1));
  1142.  
  1143. }
  1144.  
  1145. function reset() {
  1146. var li = document.getElementsByTagName('li');
  1147.  
  1148. for (var i = 0; i <= li.length; i++) {
  1149. document.getElementsByTagName('ul')[0].removeChild(li[i]);
  1150. }
  1151.  
  1152. }
  1153.  
  1154. function dodajLjude(textItem) {
  1155. var li = document.createElement('li');
  1156. var tekst = document.createTextNode(textItem);
  1157. li.appendChild(tekst);
  1158. return li;
  1159. }
  1160.  
  1161.  
  1162. HTML FILE
  1163.  
  1164. <!DOCTYPE html>
  1165.  
  1166. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  1167. <head>
  1168. <meta charset="utf-8" />
  1169. <title>Zadatak 41</title>
  1170. <link href="~/css/Zadatak41.css" rel="stylesheet" />
  1171. <link href="~/css/Zadatak41.css" rel="stylesheet" />
  1172. <script src="~/js/jquery-1.11.1.min.js"></script>
  1173. <script src="JavaScript.js"></script>
  1174. </head>
  1175. <body>
  1176. <div>
  1177. <fieldset class="floatL">
  1178. <legend>Odaberi kolegij</legend>
  1179. <input type="button" value="07019" />
  1180. <input type="button" value="07029" />
  1181. <input type="button" value="07038" />
  1182. </fieldset>
  1183. <fieldset class="floatL">
  1184. <legend>Nastavnici i asistenti</legend>
  1185. <ul></ul>
  1186. </fieldset>
  1187. </div>
  1188. </body>
  1189. </html>
  1190.  
  1191. //42
  1192.  
  1193. XSD FILE
  1194.  
  1195. <?xml version="1.0" encoding="utf-8"?>
  1196. <xs:schema id="XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  1197.  
  1198. <xs:element name="podaci" type="tipIshod"></xs:element>
  1199.  
  1200. <xs:complexType name="tipIshod">
  1201. <xs:sequence>
  1202. <xs:element name="ishodUcenja" maxOccurs="unbounded">
  1203. <xs:complexType>
  1204. <xs:sequence>
  1205. <xs:element name="poglavlje" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
  1206. </xs:sequence>
  1207. <xs:attribute name="broj">
  1208. <xs:simpleType>
  1209. <xs:restriction base="xs:string">
  1210. <xs:pattern value="[0-9]{1}"/>
  1211. </xs:restriction>
  1212. </xs:simpleType>
  1213. </xs:attribute>
  1214. </xs:complexType>
  1215. </xs:element>
  1216. </xs:sequence>
  1217. </xs:complexType>
  1218.  
  1219.  
  1220. </xs:schema>
  1221.  
  1222. XML FILE
  1223. <?xml version="1.0" encoding="utf-8" ?>
  1224. <podaci xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  1225. xsi:noNamespaceSchemaLocation="XMLSchema.xsd">
  1226. <ishodUcenja broj="1" bodova="25">
  1227. <poglavlje>HTML uvod</poglavlje>
  1228. <poglavlje>Tablice</poglavlje>
  1229. <poglavlje>Obrasci</poglavlje>
  1230. </ishodUcenja>
  1231. <ishodUcenja broj="2" bodova="15">
  1232. <poglavlje>CSS uvod</poglavlje>
  1233. <poglavlje>CSS napredni</poglavlje>
  1234. </ishodUcenja>
  1235. <ishodUcenja broj="3" bodova="20">
  1236. <poglavlje>JavaScript</poglavlje>
  1237. </ishodUcenja>
  1238. <ishodUcenja broj="4" bodova="20">
  1239. <poglavlje>XML i JavaScript</poglavlje>
  1240. <poglavlje>DTD</poglavlje>
  1241. <poglavlje>XMLSchema</poglavlje>
  1242. </ishodUcenja>
  1243. <ishodUcenja broj="5" bodova="10">
  1244. <poglavlje>XSLT</poglavlje>
  1245. <poglavlje>XPath</poglavlje>
  1246. </ishodUcenja>
  1247. </podaci>
  1248.  
  1249. //43
  1250.  
  1251. XSD file
  1252.  
  1253. <?xml version="1.0" encoding="utf-8"?>
  1254. <xs:schema id="XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  1255. <xs:element name="podaci">
  1256. <xs:complexType>
  1257. <xs:sequence>
  1258. <xs:element name="osoba" maxOccurs="unbounded" type="tipOsoba"/>
  1259. </xs:sequence>
  1260. </xs:complexType>
  1261. </xs:element>
  1262.  
  1263. <xs:complexType name="tipOsoba">
  1264. <xs:sequence>
  1265. <xs:element name="ime" type="xs:string"/>
  1266. <xs:element name="prezime" type="xs:string"/>
  1267. <xs:element name="kontakt">
  1268. <xs:complexType>
  1269. <xs:attribute name="tel" type="telefon"/>
  1270. <xs:attribute name="gsm" type="mob"/>
  1271. <xs:attribute name="email" type="mail"/>
  1272. </xs:complexType>
  1273. </xs:element>
  1274. </xs:sequence>
  1275. <xs:attribute name="oib" type="oib"/>
  1276. </xs:complexType>
  1277.  
  1278. <xs:simpleType name="oib">
  1279. <xs:restriction base="xs:integer">
  1280. <xs:pattern value="[0-9]{11}"/>
  1281. </xs:restriction>
  1282. </xs:simpleType>
  1283.  
  1284. <xs:simpleType name="telefon">
  1285. <xs:restriction base="xs:string">
  1286. <xs:pattern value="0[0-9]{1,2}[0-9]{7}"/>
  1287. </xs:restriction>
  1288. </xs:simpleType>
  1289.  
  1290. <xs:simpleType name="mob">
  1291. <xs:restriction base="xs:string">
  1292. <xs:pattern value="[091|092|095|097|098|099][0-9]{7}"/>
  1293. </xs:restriction>
  1294. </xs:simpleType>
  1295.  
  1296. <xs:simpleType name="mail">
  1297. <xs:restriction base="xs:string">
  1298. <xs:pattern value="[a-zA-Z0-9]+@[a-z-A-Z0-9]+\.[a-zA-Z]{2,3,4}"/>
  1299. </xs:restriction>
  1300. </xs:simpleType>
  1301.  
  1302. </xs:schema>
  1303.  
  1304. HTML file
  1305.  
  1306. <!DOCTYPE html>
  1307. <html xmlns="http://www.w3.org/1999/xhtml">
  1308. <head>
  1309. <title>Zadatak 43</title>
  1310. <link href="~/css/Stilovi.css" rel="stylesheet" />
  1311. <link href="~/css/Zadatak43.css" rel="stylesheet" />
  1312. <script src="jquery-1.11.1.min.js"></script>
  1313. <script>
  1314.  
  1315. window.onload = ucitajXML;
  1316.  
  1317. var imeDatoteke = 'Zadatak43.xml';
  1318.  
  1319. function ucitajXML() {
  1320. xmlhr = new XMLHttpRequest();
  1321. xmlhr.open('GET', imeDatoteke, true);
  1322. xmlhr.onreadystatechange = onChange;
  1323. xmlhr.send();
  1324.  
  1325. lista = document.getElementsByTagName('select')[0];
  1326. lista.onchange = ispis;
  1327.  
  1328. gumbUredi = document.getElementById('btnUredi');
  1329. gumbUredi.onclick = uredi;
  1330.  
  1331. gumbObrisi = document.getElementById('btnObrisi');
  1332. gumbObrisi.onclick = obrisi;
  1333. }
  1334.  
  1335. function onChange() {
  1336. if (xmlhr.readyState == 4) {
  1337. podaci();
  1338. }
  1339.  
  1340. }
  1341.  
  1342. function podaci() {
  1343.  
  1344. xmlDom = xmlhr.responseXML;
  1345. cvorOsoba = xmlDom.getElementsByTagName('osoba');
  1346.  
  1347. for (var i = 0; i < cvorOsoba.length; i++) {
  1348. var ime = cvorOsoba[i].getElementsByTagName('ime')[0].firstChild.nodeValue;
  1349. var prezime = cvorOsoba[i].getElementsByTagName('prezime')[0].firstChild.nodeValue;
  1350. var kontakt = cvorOsoba[i].getElementsByTagName('kontakt')[0];
  1351. var email = kontakt.attributes[2].value;
  1352.  
  1353. var select = document.getElementsByTagName('select')[0];
  1354. var punoIme = ime + ' ' + prezime;
  1355. select.appendChild(dodajUselect(punoIme, email));
  1356. }
  1357.  
  1358. }//kraj podaci
  1359.  
  1360. function dodajUselect(textItem, mail) {
  1361. var option = document.createElement('option');
  1362. var tekst = document.createTextNode(textItem);
  1363. option.appendChild(tekst);
  1364. option.setAttribute('value', mail);
  1365. return option;
  1366. }
  1367.  
  1368. function ispis() {
  1369. var index = lista.selectedIndex;
  1370.  
  1371. document.getElementById('txtEmail').value = cvorOsoba[index].getElementsByTagName('kontakt')[0].attributes[2].value;
  1372.  
  1373. }
  1374.  
  1375. function uredi() {
  1376. var index = lista.selectedIndex;
  1377.  
  1378. cvorOsoba[index].getElementsByTagName('kontakt')[0].attributes[2].value = document.getElementById('txtEmail').value;
  1379.  
  1380. }
  1381.  
  1382. function obrisi() {
  1383. var index = lista.selectedIndex;
  1384.  
  1385. if (index != -1) {
  1386. xmlDom.documentElement.removeChild(cvorOsoba[index]);
  1387. reset();
  1388. }
  1389.  
  1390. }
  1391.  
  1392. function reset() {
  1393. $('#txtEmail').val('');
  1394. $('select').empty();
  1395. podaci();
  1396. }
  1397.  
  1398.  
  1399.  
  1400. </script>
  1401.  
  1402.  
  1403.  
  1404. </head>
  1405.  
  1406.  
  1407.  
  1408. <body>
  1409. <div id="container">
  1410. <label>Osoba:</label>
  1411. <select id="ddlOsoba">
  1412. </select>
  1413. <label>Email:</label>
  1414. <input type="text" name="email" value="" id="txtEmail" />
  1415. <div>
  1416. <input type="button" value="Uredi E-mail" id="btnUredi" />
  1417. <input type="button" value="Obriši osobu" id="btnObrisi" />
  1418. </div>
  1419. </div>
  1420. </body>
  1421. </html>
  1422.  
  1423. XML file
  1424.  
  1425. <?xml version="1.0" encoding="utf-8" ?>
  1426. <podaci xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  1427. xsi:noNamespaceSchemaLocation="XMLSchema.xsd">
  1428.  
  1429. <osoba oib="12345678901">
  1430. <ime>Luka</ime>
  1431. <prezime>Lukić</prezime>
  1432. <kontakt tel="017894562" gsm="0916543217" email="luka@mail.hr" />
  1433. </osoba>
  1434. <osoba oib="45678912345">
  1435. <ime>Ana</ime>
  1436. <prezime>Anan</prezime>
  1437. <kontakt tel="018523694" gsm="0923579516" email="ana@googlemail.hr" />
  1438. </osoba>
  1439. <osoba oib="98732165458">
  1440. <ime>Niko</ime>
  1441. <prezime>Nikolić</prezime>
  1442. <kontakt tel="017789625" gsm="0988524563" email="nn@yahoo.com" />
  1443. </osoba>
  1444. <osoba oib="13467958205">
  1445. <ime>Maja</ime>
  1446. <prezime>Čabraja</prezime>
  1447. <kontakt tel="0215566845" gsm="0958726615" email="cabraja@email.hr" />
  1448. </osoba>
  1449. </podaci>
  1450.  
  1451. //51
  1452.  
  1453. XSLT file
  1454.  
  1455. <?xml version="1.0" encoding="utf-8"?>
  1456. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  1457.  
  1458. <xsl:template match="/">
  1459. <html>
  1460. <body>
  1461.  
  1462. <ul>
  1463. <xsl:for-each select="podaci/kolegij">
  1464. <xsl:sort order="ascending" data-type="text" select="@semestar"/>
  1465. <li>
  1466. <xsl:value-of select="naziv"/>
  1467. <ul>
  1468. <xsl:for-each select="ishodiUcenja/ishod">
  1469. <li>
  1470. I<xsl:value-of select="@broj"/> [bodova: <xsl:value-of select="@bodova"/>]
  1471. <ul>
  1472. <xsl:for-each select="poglavlje">
  1473. <xsl:sort order="ascending" data-type="text" select="poglavlje"/>
  1474. <li>
  1475. <xsl:value-of select="."/>
  1476. </li>
  1477. </xsl:for-each>
  1478. </ul>
  1479. </li>
  1480. </xsl:for-each>
  1481. </ul>
  1482. </li>
  1483. </xsl:for-each>
  1484. </ul>
  1485.  
  1486.  
  1487.  
  1488.  
  1489. </body>
  1490. </html>
  1491. </xsl:template>
  1492. </xsl:stylesheet>
  1493.  
  1494. XML file
  1495. <?xml version="1.0" encoding="utf-8" ?>
  1496. <?xml-stylesheet type="text/xsl" href="XSLTFile.xslt"?>
  1497. <podaci>
  1498. <kolegij oznaka="07038" ects="5" semestar="5" predavanja="30" vjezbe="30">
  1499. <naziv>Pristup podacima iz programskog koda</naziv>
  1500. <ishodiUcenja>
  1501. <ishod broj="1" bodova="15">
  1502. <poglavlje>ADO.NET</poglavlje>
  1503. <poglavlje>Klasa Connection</poglavlje>
  1504. <poglavlje>Klasa Command</poglavlje>
  1505. <poglavlje>Klasa DataReader</poglavlje>
  1506. <poglavlje>Klasa Parameter</poglavlje>
  1507. <poglavlje>BLOB vrijednosti</poglavlje>
  1508. <poglavlje>Transakcije</poglavlje>
  1509. </ishod>
  1510. <ishod broj="2" bodova="10">
  1511. <poglavlje>JDBC</poglavlje>
  1512. <poglavlje>Sučelje Statement</poglavlje>
  1513. <poglavlje>Pozivanjeprocedure s parametrima</poglavlje>
  1514. <poglavlje>Upravljanje transakcijama</poglavlje>
  1515. </ishod>
  1516. <ishod broj="3" bodova="20">
  1517. <poglavlje>DataSet</poglavlje>
  1518. <poglavlje>DataTable</poglavlje>
  1519. <poglavlje>DataColumn</poglavlje>
  1520. <poglavlje>DataRow</poglavlje>
  1521. <poglavlje>DataAdapter</poglavlje>
  1522. <poglavlje>Konflikti prilikom spremanja podataka</poglavlje>
  1523. <poglavlje>DataView</poglavlje>
  1524. </ishod>
  1525. <ishod broj="4" bodova="3">
  1526. <poglavlje>DAAB - DataAccessAplicationBlock</poglavlje>
  1527. <poglavlje>DAAB - SqlHelper</poglavlje>
  1528. </ishod>
  1529. <ishod broj="5" bodova="5">
  1530. <poglavlje>Tipizirani DataSet</poglavlje>
  1531. </ishod>
  1532. <ishod broj="6" bodova="8">
  1533. <poglavlje>Podatkovno povezive kontrole</poglavlje>
  1534. <poglavlje>GridView kontrola</poglavlje>
  1535. <poglavlje>DataSource komponente</poglavlje>
  1536. <poglavlje>Podatkovno-povezivajući izrazi</poglavlje>
  1537. <poglavlje>Validacija unosa</poglavlje>
  1538. <poglavlje>Prilagođeno bojanje</poglavlje>
  1539. </ishod>
  1540. <ishod broj="7" bodova="5">
  1541. <poglavlje>XmlReader</poglavlje>
  1542. <poglavlje>XmlWriter</poglavlje>
  1543. <poglavlje>Oblikovanje XML izlaza</poglavlje>
  1544. <poglavlje>XML DOM</poglavlje>
  1545. <poglavlje>XmlDocument</poglavlje>
  1546. <poglavlje>XmlNodeList</poglavlje>
  1547. </ishod>
  1548. <ishod broj="8" bodova="15">
  1549. <poglavlje>Entity Framework</poglavlje>
  1550. <poglavlje>Database First</poglavlje>
  1551. <poglavlje>Model First</poglavlje>
  1552. <poglavlje>Code First</poglavlje>
  1553. <poglavlje>Zadavanje upita u entitetskoj okolini</poglavlje>
  1554. </ishod>
  1555. </ishodiUcenja>
  1556. <nastavnik email="bojan.fulanovic@algebra.hr">Bojan Fulanović</nastavnik>
  1557. <asistent email="mario.zagar@hotmail.com">Mario Žagar</asistent>
  1558. </kolegij>
  1559. <kolegij oznaka="07019" ects="5" semestar="3" predavanja="30" vjezbe="30">
  1560. <naziv>Standardi u primjeni internetske tehnologije</naziv>
  1561. <ishodiUcenja>
  1562. <ishod broj="1" bodova="25">
  1563. <poglavlje>HTML uvod</poglavlje>
  1564. <poglavlje>Tablice</poglavlje>
  1565. <poglavlje>Obrasci</poglavlje>
  1566. </ishod>
  1567. <ishod broj="2" bodova="15">
  1568. <poglavlje>CSS uvod</poglavlje>
  1569. <poglavlje>CSS napredni</poglavlje>
  1570. </ishod>
  1571. <ishod broj="3" bodova="20">
  1572. <poglavlje>JavaScript</poglavlje>
  1573. </ishod>
  1574. <ishod broj="4" bodova="20">
  1575. <poglavlje>XML i JavaScript</poglavlje>
  1576. <poglavlje>DTD</poglavlje>
  1577. <poglavlje>XMLSchema</poglavlje>
  1578. </ishod>
  1579. <ishod broj="5" bodova="10">
  1580. <poglavlje>XSLT</poglavlje>
  1581. <poglavlje>XPath</poglavlje>
  1582. </ishod>
  1583. </ishodiUcenja>
  1584. <nastavnik email="bojan.fulanovic@algebra.hr">Bojan Fulanović</nastavnik>
  1585. <asistent email="mario.fabijanic@racunarstvo.hr">Mario Fabijanić</asistent>
  1586. <asistent email="a.stojanovic@live.com">Aleksandar Stojanović</asistent>
  1587. </kolegij>
  1588. <kolegij oznaka="07029" ects="5" semestar="4" predavanja="30" vjezbe="30">
  1589. <naziv>Razvoj web aplikacija</naziv>
  1590. <ishodiUcenja>
  1591. <ishod broj="1" bodova="28">
  1592. <poglavlje>Uvod u WebForms</poglavlje>
  1593. <poglavlje>Životni ciklus WebForme</poglavlje>
  1594. <poglavlje>Validacijske kontrole</poglavlje>
  1595. <poglavlje>Mehanizmi čuvanja stanja</poglavlje>
  1596. <poglavlje>Korisničke kontrole</poglavlje>
  1597. <poglavlje>Autentikacija i autorizacija</poglavlje>
  1598. </ishod>
  1599. <ishod broj="2" bodova="15">
  1600. <poglavlje>Master stranice</poglavlje>
  1601. <poglavlje>Teme</poglavlje>
  1602. <poglavlje>Navigacija</poglavlje>
  1603. <poglavlje>Globalizacija i lokalizacija</poglavlje>
  1604. <poglavlje>Optimizacija keširanjem</poglavlje>
  1605. <poglavlje>Upravljanje iznimkama</poglavlje>
  1606. </ishod>
  1607. <ishod broj="3" bodova="15">
  1608. <poglavlje>Rad s podacima iz baze podataka</poglavlje>
  1609. <poglavlje>Podatkovno povezive kontrole</poglavlje>
  1610. </ishod>
  1611. <ishod broj="4" bodova="25">
  1612. <poglavlje>MVC</poglavlje>
  1613. <poglavlje>MVC kontroleri</poglavlje>
  1614. <poglavlje>Razor pogledi</poglavlje>
  1615. <poglavlje>Modeli</poglavlje>
  1616. <poglavlje>Validacija</poglavlje>
  1617. </ishod>
  1618. </ishodiUcenja>
  1619. <nastavnik email="bojan.fulanovic@algebra.hr">Bojan Fulanović</nastavnik>
  1620. <asistent email="danijel.kucak@algebra.hr">Danijel Kučak</asistent>
  1621. </kolegij>
  1622.  
  1623. </podaci>
  1624.  
  1625. //52
  1626.  
  1627. XSLT file
  1628.  
  1629. <?xml version="1.0" encoding="utf-8"?>
  1630. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  1631.  
  1632.  
  1633. <xsl:template match="/">
  1634.  
  1635. <html>
  1636. <body>
  1637.  
  1638. <ul>
  1639. <xsl:for-each select="podaci/kolegij">
  1640. <xsl:sort order="descending" data-type="text" select="@semestar"/>
  1641. <li style="list-style-type:none">
  1642. <h3>
  1643. <xsl:value-of select="naziv"/>
  1644. </h3>
  1645. <xsl:for-each select="ishodiUcenja/ishod">
  1646. <li style="list-style-type:none">
  1647. I<xsl:value-of select="@broj"/> - [<xsl:value-of select="count(poglavlje)"/> poglavlja, bodova: <xsl:value-of select="@bodova"/>]
  1648. </li>
  1649. </xsl:for-each>
  1650. <li style="list-style-type:none">
  1651. Ukupno ishoda:<xsl:value-of select="count(ishodiUcenja/ishod)"/>
  1652. </li>
  1653. <li style="list-style-type:none">
  1654. Ukupno bodova: <xsl:value-of select="sum(ishodiUcenja/ishod/@bodova)"/>
  1655. </li>
  1656. </li>
  1657. </xsl:for-each>
  1658. </ul>
  1659.  
  1660. </body>
  1661. </html>
  1662.  
  1663. </xsl:template>
  1664. </xsl:stylesheet>
  1665.  
  1666. XML file
  1667.  
  1668. <?xml version="1.0" encoding="utf-8" ?>
  1669. <?xml-stylesheet type="text/xsl" href="XSLTFile2.xslt"?>
  1670. <podaci>
  1671. <kolegij oznaka="07038" ects="5" semestar="5" predavanja="30" vjezbe="30">
  1672. <naziv>Pristup podacima iz programskog koda</naziv>
  1673. <ishodiUcenja>
  1674. <ishod broj="1" bodova="30">
  1675. <poglavlje>ADO.NET</poglavlje>
  1676. <poglavlje>Klasa Connection</poglavlje>
  1677. <poglavlje>Klasa Command</poglavlje>
  1678. <poglavlje>Klasa DataReader</poglavlje>
  1679. <poglavlje>Klasa Parameter</poglavlje>
  1680. <poglavlje>BLOB vrijednosti</poglavlje>
  1681. <poglavlje>Transakcije</poglavlje>
  1682. </ishod>
  1683. <ishod broj="2" bodova="25">
  1684. <poglavlje>JDBC</poglavlje>
  1685. <poglavlje>Sučelje Statement</poglavlje>
  1686. <poglavlje>Pozivanjeprocedure s parametrima</poglavlje>
  1687. <poglavlje>Upravljanje transakcijama</poglavlje>
  1688. </ishod>
  1689. <ishod broj="3" bodova="30">
  1690. <poglavlje>DataSet</poglavlje>
  1691. <poglavlje>DataTable</poglavlje>
  1692. <poglavlje>DataColumn</poglavlje>
  1693. <poglavlje>DataRow</poglavlje>
  1694. <poglavlje>DataAdapter</poglavlje>
  1695. <poglavlje>Konflikti prilikom spremanja podataka</poglavlje>
  1696. <poglavlje>DataView</poglavlje>
  1697. </ishod>
  1698. </ishodiUcenja>
  1699. <nastavnik email="bojan.fulanovic@algebra.hr">Bojan Fulanović</nastavnik>
  1700. <asistent email="mario.zagar@hotmail.com">Mario Žagar</asistent>
  1701. </kolegij>
  1702. <kolegij oznaka="07019" ects="5" semestar="3" predavanja="30" vjezbe="30">
  1703. <naziv>Standardi u primjeni internetske tehnologije</naziv>
  1704. <ishodiUcenja>
  1705. <ishod broj="1" bodova="25">
  1706. <poglavlje>HTML uvod</poglavlje>
  1707. <poglavlje>Tablice</poglavlje>
  1708. <poglavlje>Obrasci</poglavlje>
  1709. </ishod>
  1710. <ishod broj="2" bodova="15">
  1711. <poglavlje>CSS uvod</poglavlje>
  1712. <poglavlje>CSS napredni</poglavlje>
  1713. </ishod>
  1714. <ishod broj="3" bodova="20">
  1715. <poglavlje>JavaScript</poglavlje>
  1716. </ishod>
  1717. <ishod broj="4" bodova="20">
  1718. <poglavlje>XML i JavaScript</poglavlje>
  1719. <poglavlje>DTD</poglavlje>
  1720. <poglavlje>XMLSchema</poglavlje>
  1721. </ishod>
  1722. <ishod broj="5" bodova="10">
  1723. <poglavlje>XSLT</poglavlje>
  1724. <poglavlje>XPath</poglavlje>
  1725. </ishod>
  1726. </ishodiUcenja>
  1727. <nastavnik email="bojan.fulanovic@algebra.hr">Bojan Fulanović</nastavnik>
  1728. <asistent email="mario.fabijanic@racunarstvo.hr">Mario Fabijanić</asistent>
  1729. <asistent email="a.stojanovic@live.com">Aleksandar Stojanović</asistent>
  1730. </kolegij>
  1731. <kolegij oznaka="07029" ects="5" semestar="4" predavanja="30" vjezbe="30">
  1732. <naziv>Razvoj web aplikacija</naziv>
  1733. <ishodiUcenja>
  1734. <ishod broj="1" bodova="28">
  1735. <poglavlje>Uvod u WebForms</poglavlje>
  1736. <poglavlje>Životni ciklus WebForme</poglavlje>
  1737. <poglavlje>Validacijske kontrole</poglavlje>
  1738. <poglavlje>Mehanizmi čuvanja stanja</poglavlje>
  1739. <poglavlje>Korisničke kontrole</poglavlje>
  1740. <poglavlje>Autentikacija i autorizacija</poglavlje>
  1741. </ishod>
  1742. <ishod broj="2" bodova="15">
  1743. <poglavlje>Master stranice</poglavlje>
  1744. <poglavlje>Teme</poglavlje>
  1745. <poglavlje>Navigacija</poglavlje>
  1746. <poglavlje>Globalizacija i lokalizacija</poglavlje>
  1747. <poglavlje>Optimizacija keširanjem</poglavlje>
  1748. <poglavlje>Upravljanje iznimkama</poglavlje>
  1749. </ishod>
  1750. <ishod broj="3" bodova="15">
  1751. <poglavlje>Rad s podacima iz baze podataka</poglavlje>
  1752. <poglavlje>Podatkovno povezive kontrole</poglavlje>
  1753. </ishod>
  1754. <ishod broj="4" bodova="25">
  1755. <poglavlje>MVC</poglavlje>
  1756. <poglavlje>MVC kontroleri</poglavlje>
  1757. <poglavlje>Razor pogledi</poglavlje>
  1758. <poglavlje>Modeli</poglavlje>
  1759. <poglavlje>Validacija</poglavlje>
  1760. </ishod>
  1761. </ishodiUcenja>
  1762. <nastavnik email="bojan.fulanovic@algebra.hr">Bojan Fulanović</nastavnik>
  1763. <asistent email="danijel.kucak@algebra.hr">Danijel Kučak</asistent>
  1764. </kolegij>
  1765.  
  1766. </podaci>
  1767.  
  1768.  
  1769. //Zadatak41 - U XMLSchema se radi sve
  1770.  
  1771.  
  1772. <?xml version="1.0" encoding="utf-8"?>
  1773. <xs:schema id="Zadatak41"
  1774. targetNamespace="http://tempuri.org/Zadatak41.xsd"
  1775. elementFormDefault="qualified"
  1776. xmlns="http://tempuri.org/Zadatak41.xsd"
  1777. xmlns:mstns="http://tempuri.org/Zadatak41.xsd"
  1778. xmlns:xs="http://www.w3.org/2001/XMLSchema">
  1779. <xs:element name="podaci">
  1780. <xs:complexType>
  1781. <xs:sequence>
  1782. <xs:element name="osoba" maxOccurs="50">
  1783. <xs:complexType>
  1784. <xs:sequence>
  1785. <xs:element name="ime" type="xs:string"></xs:element>
  1786. <xs:element name="prezime" type="xs:string"></xs:element>
  1787. <xs:element name="email" type="mail"></xs:element>
  1788. <xs:element name="telefon">
  1789. <xs:complexType>
  1790. <xs:attribute name="fiksni" use="optional" type="tel"></xs:attribute>
  1791. <xs:attribute name="gsm" use="required" type="mob"></xs:attribute>
  1792. </xs:complexType>
  1793. </xs:element>
  1794. </xs:sequence>
  1795. <xs:attribute name="oib" type="indet" use="required"></xs:attribute>
  1796. </xs:complexType>
  1797. </xs:element>
  1798. </xs:sequence>
  1799. </xs:complexType>
  1800. </xs:element>
  1801. <xs:element name="tel">
  1802. <xs:simpleType>
  1803. <xs:restriction base="xs:string">
  1804. <xs:pattern value="[0-9]{4}\.[0-9]{3}"></xs:pattern>
  1805. </xs:restriction>
  1806. </xs:simpleType>
  1807. </xs:element>
  1808. <xs:element name="mob">
  1809. <xs:simpleType>
  1810. <xs:restriction base="xs:string">
  1811. <xs:pattern value="09[1|2|8]\.[0-9]{4}\.[0-9]{3}"></xs:pattern>
  1812. </xs:restriction>
  1813. </xs:simpleType>
  1814. </xs:element>
  1815. <xs:element name="oib">
  1816. <xs:simpleType>
  1817. <xs:restriction base="xs:string">
  1818. <xs:pattern value="[0-9]{11}"></xs:pattern>
  1819. </xs:restriction>
  1820. </xs:simpleType>
  1821. </xs:element>
  1822. <xs:element name="mail">
  1823. <xs:simpleType>
  1824. <xs:restriction base="xs:string">
  1825. <xs:pattern value="[a-z]+@[a-z]+\.[a-z]{2,4}"></xs:pattern>
  1826. </xs:restriction>
  1827. </xs:simpleType>
  1828. </xs:element>
  1829. </xs:schema>
  1830. //Zadatak42 - sve u JSu radim, samo u HTML referenca
  1831. window.onload = ucitajXML;
  1832. var imeDatoteke = 'Zadatak42.xml';
  1833. function ucitajXML() {
  1834. xmlhr = new XMLHttpRequest();
  1835. xmlhr.open('GET', imeDatoteke, true);
  1836. xmlhr.onreadystatechange = onChange;
  1837. xmlhr.send();
  1838. }
  1839. function onChange() {
  1840. if (xmlhr.readyState == 4) {
  1841. podaci();
  1842. }
  1843. }
  1844. function podaci() {
  1845. var ispis = "";
  1846. xmlDom = xmlhr.responseXML;
  1847. dom = xmlDom.documentElement;
  1848. cvorOsoba = dom.getElementsByTagName('osoba');
  1849. for (var i = 0; i < cvorOsoba.length; i++) {
  1850. var osoba = dom.getElementsByTagName('osoba')[i];
  1851. var ime = osoba.getElementsByTagName('ime')[0].firstChild.nodeValue;
  1852. var prezime = osoba.getElementsByTagName('prezime')[0].firstChild.nodeValue;
  1853. var oib = osoba.attributes[0].value;
  1854. ispis += ime + " " + prezime + "[" + "oib:" + oib + "]\n";
  1855. }
  1856. console.log(ispis);
  1857. }
  1858.  
  1859.  
  1860.  
  1861. //Zadatak43 - U JSu radim sve, samo referenca u HTMLu
  1862. /// <reference path="jquery-1.11.3.min.js" />
  1863. var xmlhr, xmlDom, cvorOsoba;
  1864. window.onload = function () {
  1865. ucitajXML();
  1866. }
  1867. function ucitajXML() {
  1868. xmlhr = new XMLHttpRequest();
  1869. xmlhr.open("GET", "XMLFile.xml", true);
  1870. xmlhr.onreadystatechange = function () {
  1871. if (xmlhr.readyState == 4) {
  1872. prikazPodataka();
  1873. }
  1874. }
  1875. xmlhr.send();
  1876. lista = document.getElementsByTagName("select")[0];
  1877. lista.onchange = ispis;
  1878. $("#btnDodaj").click(dodajOsobu);
  1879. $("#btnUredi").click(urediOsobu);
  1880. $("#btnObrisi").click(obrisiOsobu);
  1881. }
  1882. function prikazPodataka() {
  1883. xmlDom = xmlhr.responseXML;
  1884. cvorOsoba = xmlDom.getElementsByTagName("osoba");
  1885. for (var i = 0; i < cvorOsoba.length; i++) {
  1886. var oib = cvorOsoba[i].attributes[0].value;
  1887. var ime = cvorOsoba[i].getElementsByTagName("ime")[0].firstChild.nodeValue;
  1888. var prezime = cvorOsoba[i].getElementsByTagName("prezime")[0].firstChild.nodeValue;
  1889. var select = document.getElementsByTagName("select")[0];
  1890. var imeIprezime = ime + " " + prezime;
  1891. select.appendChild(ubaciSelectu(imeIprezime, oib));
  1892. }
  1893. }
  1894. function ubaciSelectu(name, data) {
  1895. var option = document.createElement("option");
  1896. var tekst = document.createTextNode(name);
  1897. option.setAttribute("value", data);
  1898. option.appendChild(tekst);
  1899. return option;
  1900. }
  1901. function ispis() {
  1902. var index = lista.selectedIndex;
  1903. var ime = cvorOsoba[index].getElementsByTagName("ime")[0].firstChild.nodeValue;
  1904. var prezime = cvorOsoba[index].getElementsByTagName("prezime")[0].firstChild.nodeValue;
  1905. var oib = cvorOsoba[index].attributes[0].value;
  1906. document.getElementById("txtIme").value = ime;
  1907. document.getElementById("txtPrezime").value = prezime;
  1908. document.getElementById("txtOIB").value = oib;
  1909. }
  1910. function dodajOsobu() {
  1911. var imeDodaj = $("#txtIme").val();
  1912. var prezimeDodaj = $("#txtPrezime").val();
  1913. var oibDodaj = $("#txtOIB").val();
  1914. if (imeDodaj == "" || prezimeDodaj == "" || oibDodaj == "") {
  1915. alert("Sva polja su obavezna!!!");
  1916. }
  1917. var cvorOsoba = xmlDom.createElement("osoba");
  1918. cvorOsoba.setAttribute("oib", oibDodaj);
  1919. var cvorIme = xmlDom.createElement("ime");
  1920. cvorIme.appendChild(xmlDom.createTextNode(imeDodaj));
  1921. var cvorPrezime = xmlDom.createElement("prezime");
  1922. cvorPrezime.appendChild(xmlDom.createTextNode(prezimeDodaj));
  1923. cvorOsoba.appendChild(cvorIme);
  1924. cvorOsoba.appendChild(cvorPrezime);
  1925. xmlDom.documentElement.appendChild(cvorOsoba);
  1926. $("select").empty();
  1927. reset();
  1928. }
  1929. function urediOsobu() {
  1930. var selectedOption = document.getElementsByTagName("select")[0];
  1931. var index = selectedOption.selectedIndex;
  1932. cvorOsoba[index].getElementsByTagName("ime")[0].firstChild.nodeValue = document.getElementById("txtIme").value;
  1933. cvorOsoba[index].getElementsByTagName("prezime")[0].firstChild.nodeValue = document.getElementById("txtPrezime").value;
  1934. cvorOsoba[index].attributes[0].value = document.getElementById("txtOIB").value;
  1935. reset();
  1936. }
  1937. function obrisiOsobu() {
  1938. var index = lista.selectedIndex;
  1939. if (index != -1) {
  1940. xmlDom.documentElement.removeChild(cvorOsoba[index]);
  1941. reset();
  1942. }
  1943. }
  1944. function reset() {
  1945. $("#txtIme, #txtPrezime, #txtOIB").val("");
  1946. $("#txtIme").focus();
  1947. $("select").empty();
  1948. prikazPodataka();
  1949. }
Add Comment
Please, Sign In to add comment