<html>
<head>
<style type="text/css">
#burimi {
position:absolute;
left: 50px;
top: 50px;
width: 100px;
height: 100px;
background-color: #ff0000;
z-index:1;
}
#destinacioni {
position:absolute;
left: 600px;
top: 50px;
width: 100px;
height: 100px;
background-color: #0000ff;
z-index:1;
}
#paketa {
position:absolute;
left: 50px;
top: 50px;
width: 100px;
height: 100px;
background-color: #00ff00;
z-index:2;
}
</style>
<script type="text/javascript">
function leviz() {
document.getElementById("paketa").style.left = document.getElementById("paketa").offsetLeft + 20;
if(document.getElementById("paketa").offsetLeft > 600) return;
setTimeout("leviz()", 1000);
}
</script>
</head>
<body onLoad="leviz()">
<div id="burimi"></div>
<div id="destinacioni"></div>
<div id="paketa"></div>
</body>
</html>
Rezultati:
Ushtrim 1:
Ndertoni nje faqe html qe mundeson zhvendosjen e nje katrori me ngjyre jeshile duke nisur levizjen e tij nga nje katror me ngjyre te kuqe te nje katror destinacion me ngjyre blu.
Ushtrim 2:
Ndertoni nje faqe html dhe javascript qe shfaq me ane te nje dropdown nje liste me shtete. Ne zgjedhjen e nje shteti te mbushet ne menyre dinamike nje tjeter dropdown me nje liste me qytete te shtetit perkates.
<html>
<head>
<title>State/City</title>
<script type="text/javascript" >
var states= Object();
states['Albania'] = '|Tirana|Durres|Berat|Vlore|Korce';
states['France'] = '|Paris|qytet2|qytet3|qytet4';
states['Germany'] = '|Berlin|Hamburg';
states['Greece'] = '|Athens|Kreta|Arta';
function FillStates()
{
for (state in states)
document.write('<option value="' + state + '">' + state + '</option>');
}
function set_city(stateSel,citySel)
{
var cityArr;
citySel.length = 0;
var state = stateSel.options[stateSel.selectedIndex].text;
if (states[state])
{
citySel.disabled = false;
citySel.options[0] = new Option('Zgjidh Qytetin','');
cityArr = states[state].split('|');
for (var i = 0; i < cityArr.length; i++)
citySel.options[i + 1] = new Option(cityArr[i], cityArr[i]);
}
else citySel.disabled = true;
}
</script>
</head>
<body>
<form>
<select onchange="set_city(this,city)" size="1" name="state">
<option value="" selected="selected">Zgjidh Shtetin</option>
<option value=""></option>
<script type="text/javascript">
FillStates(this);
</script>
</select>
<select name="city" size="1" disabled="disabled">
</select>
</form>
</body>
</html>
Rezultati: