Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Kupac(ime, titula, grad, broj, datum, zarada) {
- var Ime = ime;
- var Titula = titula;
- var Grad = grad;
- var Broj = broj;
- var Datum = datum;
- var Zarada = zarada;
- }
- function $(q) {
- return document.querySelectorAll(q);
- }
- window.onload = function () {
- var selekt = $("#lbPodaci")[0];
- var tit = $("#titula")[0];
- var grd = $("#grad")[0];
- var bro = $("#postanskiBroj")[0];
- var dat = $("#datumZaposlenja")[0];
- var zrd = $("#godisnjaZarada")[0];
- var kupci = [
- new Kupac('Miro Mirić', 'IT-evac', 'Zagreb', 1234, '15.10.2015', 156),
- new Kupac('Ana Anić', 'Marketing', 'Split', 4321, '12.11.2015', 256),
- new Kupac('Test Testerić', 'Biznismen', 'Rijeka', 5631, '7.12.2015', 512)
- ];
- // Sortiranje
- kupci.sort(function (left, right) {
- return left.Zarada - right.Zarada;
- });
- var vari = $("select")[0];
- for (var i = 0; i < kupci.length; i++) {
- var opt = document.createElement("option");
- opt.value = i;
- opt.innerHTML = kupci[i].Ime;
- vari.appendChild(opt);
- }
- vari.onchange = function () {
- var id = parseInt(vari.value);
- tit.innerHTML = kupci[id].titula;
- grd.innerHTML = kupci[id].grad;
- bro.innerHTML = kupci[id].broj;
- dat.innerHTML = kupci[id].datum;
- zrd.innerHTML = kupci[id].zarada;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement