Mam taki kodzik:
<?php <script type="text/javascript"> function dragDrop(e,x,y,d,b,E){ d=document;E=d.documentElement;b=d.body;if(!E)return l=d.getElementById("sciana").offsetLeft t=d.getElementById("sciana").offsetTop w=d.getElementById("sciana").offsetWidth h=d.getElementById("sciana").offsetHeight if(d.p)d.p.style.zIndex=1 with(d.p=this){ style.zIndex=10;e=e||event zx=e.layerX||e.offsetX;zy=e.layerY||e.offsetY x=parseInt(style.left+0)-e.clientX;y=parseInt(style.top+0)-e.clientY; } d.onmousemove=function(e){ e=e||event;with(d.p.style){ left=x+e.clientX+(E.scrollLeft||b.scrollLeft)+"px" leftx=x+e.clientX+(E.scrollLeft||b.scrollLeft) top=y+e.clientY+(E.scrollTop||b.scrollTop)+"px" topx=y+e.clientY+(E.scrollTop||b.scrollTop) if((leftx>((l-5))) && (leftx<((l+w))) && (topx>((t-5))) && (topx<((t+h)))){ this.onmousemove=null; alert("najechałes na krawędz"); } }return!1 } d.onmouseup=function(){ e=e||event;with(d.p.style){ left=100+"px" top=100+"px"} this.onmousemove=null } } function dragDropInit(i,j,a,t){ for(j=0;t=['div','img'][j++];) for(i=0;a=document.getElementsByTagName(t)[i++];) if(a.className=="drag")a.onmousedown=dragDrop } function addEvent(O,E,F,x){return(x=O.addEventListener)?x(E,F,1):(x=O.attachEvent)?x('on'+E,F):!1} addEvent(window,'load',dragDropInit) </script> </head> <body> <div class="drag" style="top:100px;left:100px;"><span style="width:5px; height:5px;"></span></div> <span id="sciana" style="position:absolute;left:100px;top:300px;width:100px;height:100px;background:
#000"></span> <span id="sciana" style="position:absolute;left:210px;top:300px;width:100px;height:100px;background:
#000"></span> ?>
i moje pytanie brzmi: Czy da się aby te zmienne l, t,w, h działały dla każdego span z id=sciana(bez względu ile ich jest), a nie tylko dla pierwszego?