ja bym to zrobił na javascripcie
[xml:1:671789f31a]
<form action="dalej.php" name="wspolzendne">
x1<input type="text" name="x1">
y1<input type="text" name="y1">
x2<input type="text" name="x2">
y2<input type="text" name="y2">
</form>
<img src="templates/design1/images/logo.gif" width="220" height="83" border="0" id="img"><!--wyświetlasz cały obrazek-->
<div id="ramka" style="border: dotted black 1px; background-color: transparent; filter: alpha('opacity=50'); position: Absolute">
<script>
document.onmousedown=poczatek
document.onmousemove=rusz
document.onmouseup=koniec
p=false;
function poczatek()
{
xa=window.event.offsetX;
ya=window.event.offsetY;
if(window.event.srcElement.id=="img")
{
p=true;
document.getElementById("ramka").style.height=0;
document.getElementById("ramka").style.width=0;
document.getElementById("ramka").style.left=window.event.x-1;
document.getElementById("ramka").style.top=window.event.y-1;
document.wspolzendne.x1.value=xa;
document.wspolzendne.y1.value=ya;
}
else
{
p=false;
document.getElementById("ramka").style.left=0;
document.getElementById("ramka").style.top=0;
document.getElementById("ramka").style.width=0;
document.getElementById("ramka").style.height=0;
document.wspolzendne.x1.value=0;
document.wspolzendne.y1.value=0;
}
return false;
}
function rusz()
{
xb=window.event.offsetX;
yb=window.event.offsetY;
if(p&&window.event.srcElement.id=="img")
{
w=(xb-xa)<0?0:xb-xa;
h=(yb-ya)<0?0:yb-ya;
document.getElementById("ramka").style.width=w;
document.getElementById("ramka").style.height=h;
document.wspolzendne.x2.value=xa+w;
document.wspolzendne.y2.value=ya+h;
}
return false;
}
function koniec()
{
p=false;
}
</script>[/xml:1:671789f31a]
moge sie pochwalic ze pisane na poczekaniu zmien tylko typ inputów z text na hidden
wynik na
http://krzysiek.bielicki.pl/zaznacz.php
UPDATE
Było trochę źle, ale jest lepiej.
Mam problem gdy width/height ma być ujemny. Narazie zrobiłem żeby były równe 0