aliceaod
07-16-2009, 01:50 PM
1) Script Title: DOM Drag & Drop script
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/domdrag/index.htm
3) Describe problem:
I am modifying a game. I want to make it so that you can move buildings around on a map and put them where you want on the map. I got the cookie thing figured out to remember the positions by checking the forums (ty to ddadmin for the solution). the images being dragged are hyperlinked to their maintenance page (ie: to upgrade that particular building or items in it).
When you release the mouse after you finish dragging, it takes you to the page that it's linked to. I don't want that. I want to make it so that a person has to double click on the building to go to the page after dragging it around.
I tried for days now surfing the 'net and am completely stuck (I'm not a coding wizard, obviously).
I found this which partially works (am I on the right track?):
<script type="text/javascript">
var click1 = 0;
function oneclick() {
//alert('You clicked on this once');
return false;//I commented out the first line and then added this
}
function twoclick() {
//alert('You clicked on this twice');
document.location.href="<?php echo"barn.php?town=".$town[0].""; ?>; //I commented out the first line and then added this
}
function one_click() {
click1 = setTimeout("oneclick()",300); // Make this value higher to allow slower double clicks
return false;
}
function two_click() {
if (click1 != 0) {
clearTimeout(click1);
click1 = 0;
}
twoclick();
setTimeout("if (click1 != 0) clearTimeout(click1)",1); // Netscape signals a click after a double click
}</script>
This works, but for only one of the buildings. What I can't figure out is how to get it to work with multiple linked images (there are 21 of them) or am I going about this the wrong way? How do I make it so that the dragged linked image doesn't go to the page it's linked to when the mouse button is released AND use this for multiple images?
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/domdrag/index.htm
3) Describe problem:
I am modifying a game. I want to make it so that you can move buildings around on a map and put them where you want on the map. I got the cookie thing figured out to remember the positions by checking the forums (ty to ddadmin for the solution). the images being dragged are hyperlinked to their maintenance page (ie: to upgrade that particular building or items in it).
When you release the mouse after you finish dragging, it takes you to the page that it's linked to. I don't want that. I want to make it so that a person has to double click on the building to go to the page after dragging it around.
I tried for days now surfing the 'net and am completely stuck (I'm not a coding wizard, obviously).
I found this which partially works (am I on the right track?):
<script type="text/javascript">
var click1 = 0;
function oneclick() {
//alert('You clicked on this once');
return false;//I commented out the first line and then added this
}
function twoclick() {
//alert('You clicked on this twice');
document.location.href="<?php echo"barn.php?town=".$town[0].""; ?>; //I commented out the first line and then added this
}
function one_click() {
click1 = setTimeout("oneclick()",300); // Make this value higher to allow slower double clicks
return false;
}
function two_click() {
if (click1 != 0) {
clearTimeout(click1);
click1 = 0;
}
twoclick();
setTimeout("if (click1 != 0) clearTimeout(click1)",1); // Netscape signals a click after a double click
}</script>
This works, but for only one of the buildings. What I can't figure out is how to get it to work with multiple linked images (there are 21 of them) or am I going about this the wrong way? How do I make it so that the dragged linked image doesn't go to the page it's linked to when the mouse button is released AND use this for multiple images?