posted 22 years ago
Hi Charlie,
Thanks for ur guide.I tried with my below codes but now iam facing problem if fruit does not match with the season box it should go it's original position when cursor is remove from this fruit and if it match it should remain in box.And i also want to give the scoring if matching of fruit and season correct user will get 1 point and in this way scroing will increase by 1 at every correct matching and when user click on score button user should see his/her score.can u plz tell me what will code for that.Plz help me.Below r my codes:-
------------------------------------------------
<html>
<head>
<title>Drag and Drop</title>
<script language="JavaScript">
var x=y=o=null;
if (document.layers) {
window.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
window.onmousedown=down, window.onmouseup=up, window.onmousemove=move;
}
else if (document.all)
document.onmousedown=down, document.onmouseup=up, document.onmousemove=move;
function down(e) {
if (document.all && window.event.srcElement.parentElement)
o=window.event.srcElement.parentElement, x=window.event.offsetX,
y=window.event.offsetY;
else {
if (document.layers) {
if (document.layers['o'+e.target.name]) {
o=document.layers['o'+e.target.name], x=e.layerX, y=e.layerY;
}
else return true;
}
}
return false;
}
function move(e) {
if (document.all && o)
o.style.posLeft=window.event.clientX-x, o.style.posTop=window.event.clientY-y;
else if (document.layers && o)
o.left=e.pageX-x, o.top=e.pageY-y;
return false;
}
function up() { o=null; }
//--></script>
</head>
<body>
<span id="o0" style="position:absolute; left:50; top:50; width:50;">
<img src="Apple.jpg" name="0" width="50" height="50" alt="An image in a span">
</span>
<div id="o1" style="position:absolute; left:200; top:50; width:75;">
<img src="banana.jpg" name="1" width="75" height="75" alt="An image in a div">
</div>
<div id="o2" style="position:absolute; left:350; top:50; width:55;">
<img src="grapes.jpg" name="2" width="100" height="100" alt="An image in a div">
</div>
<img src="Summer.gif" style="position:absolute;left:50; top:350;">
<img src="winter.gif" style="position:absolute;left:200; top:350;">
<img src="rainy.gif" style="position:absolute;left:350; top:350;">
</body>
</html>
-----------------------------------------------
Regards
Bikash
[ August 26, 2002: Message edited by: Bikash Paul ]