简体   繁体   中英

Calling a java script function with php on click

Ok so i have paid a coder to code me a walk around map script were users can press up and down on the keyboard and walk aroud a map using jquery. But now im trying to make it so i have a up and down image and then on click it will call the up and down function. So the suer can use the up and down keys plus clicking the images.

Here is the up function im using for when the user presses the up key on the keyboard. But now some how i need to call the same function when a image is clicked..

function move(d)
{
    if(d == "UP")
    {
        var top = (parseInt(document.getElementById('move').style.top) - 10);
        var left = parseInt(document.getElementById('move').style.left);
        if(canMove(new xy(left,top)))
        {
            document.getElementById('move').style.top = (parseInt(document.getElementById('move').style.top) - 10) + 'px';
            document.player.src = "maps/sprites/playerUp.png";
            //if(lastStep != "UP") clearTimeouts();
            //setTimeout('document.player.src="playerUp.png"', 500);
            //lastStep = "UP";
            reloadF();
        }
    }

How would i do about doing that ??

Im guessing i just need to call function move(d) and set it to up some how ?? On click of image ?

var keynum = 0;

if(window.event) { keynum = e.keyCode; }  // for IE
else if(e.which) { keynum = e.which; }    // for others browsers

if(keynum === 38) { // up
    //if KEY UP
}

if(keynum === 40) { // down
    //if KEY DOWN
}

I hope this help...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM