| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 
 | <head> 
<style type="text/css"> 
.grand_div { margin-left: 0px; margin-top: 0px; width:100%; height:200px; border: 4px solid #eeeeee; background-color:#CCFFCC; } 
.petit_div { position :relative; border-style:none; background-color:#00ced1; } 
</style> 
<script type="text/javascript"> 
var ie=document.all; 
var nn6=document.getElementById&&!document.all; 
var isdrag=false; 
var x,y; 
var dobj; 
 
function movemouse(e) { 
if (isdrag) { 
dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x; dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y; 
return false; 
} } 
 
function getcoord (e){ isdrag=false; }
 
function selectmouse(e) { 
var fobj = nn6 ? e.target : event.srcElement; 
var topelement = nn6 ? "HTML" : "BODY"; 
 
while (fobj.tagName != topelement && fobj.className != "dragme") { 
fobj = nn6 ? fobj.parentNode : fobj.parentElement; 
} 
if (fobj.className=="dragme") {
isdrag = true; 
dobj = fobj; 
tx = parseInt(dobj.style.left+0); 
ty = parseInt(dobj.style.top+0); 
x = nn6 ? e.clientX : event.clientX; 
y = nn6 ? e.clientY : event.clientY; 
document.onmousemove=movemouse; 
return false; 
} } 
 
document.onmousedown=selectmouse; 
document.onmouseup=getcoord; 
</script> 
 
</head> 
<form action="index.php?" method="post" name="adminForm" id="adminForm"> <div class=grand_div> 
<?php 
$array = array ( 
"0"=>array ( "myDiv0", "200", "50", "80", "80" ), 
"1"=>array ( "myDiv1", "200", "200", "80", "80" ), 
"2"=>array ( "myDiv2", "300", "300", "80", "80" ) ); 
 
foreach ($array as $row) { echo "<div class='petit_div' id=".$row[0]." style='position:absolute;top:".$row[1]."px;left:".$row[2]."px; background-color:#00ced1; border: 3px solid #00009C; width: ".$row[3]."px; height:".$row[4]."px; text-align:center;'> <br> ".$row[0]." </div>"; } 
?> 
</div> | 
Partager