Help - Search - Members - Calendar
Full Version: Php Equivalent Of Java Code..
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
kcc
Here's my javascript and I want to know if there is a php guy who can help me have a php equivalent of this code.

This is the code.
CODE
function moveup() {
var move=document.getElementById('move');
move.style.top = (parseInt(move.style.top,10) - 16) + 'px';
message();
}
function moveright()
{
var move=document.getElementById('move');
move.style.left = (parseInt(move.style.left,10) + 16) + 'px';
message();
}
function movedown()
{
var move=document.getElementById('move');
move.style.top = (parseInt(move.style.top,10) + 16) + 'px';
message();
}
function moveleft()
{
    var move=document.getElementById('move');
    move.style.left = (parseInt(move.style.left,10) - 16) + 'px';
    message();
}
function message()
{
    var level=Math.floor(Math.random() * 8) + 8;
    var chance=Math.floor(Math.random() * 14) + 1;
    var msg = document.getElementById("message");
    if(chance==2)
    {
        msg.innerHTML = "A level " +level+ "appeared";
    }
    else if(chance==3)
    {
        msg.innerHTML = "A level " + level + "appeared";
    }
    else
    {
        msg.innerHTML = "Keep moving around the map to find one";
    }
}
window.onload = message;

Just need help with this part. Help would be appreciated. Thanks in advance.
swordz
I'm willing to have a go, but don't know javascript. What does this do?

swordz
kcc
Well, it is a code for what I require at the moment. I need to get in php, I think you have got that.

This just basically is stupid script that makes something move on a web page and every time or on every move prints a new message. Just this. smile.gif

If you can help, thanks in advance. biggrin.gif
swordz
I suspect it's possible, but would be much slower with php - it'd have to load the page again, whereas this looks like it adjusts the css, which will be much faster. However, it should be easy to do.

swordz
kcc
Thanks, I was told the same by somebody else. I think I will stick with java here. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.