#1
  1. No Profile Picture
    Balance is everything!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    44
    Rep Power
    13

    Question Show Javascript variable on screen


    I am new to Java, I work in PHP.

    I use a Javascript on a page(html) to report the x, y coordinates to the taskbar. I need to post these values to another page, so I can pick them up and use them in PHP on the second page.

    How do I print something to the screen
    in Php I would say: "print" or "echo"
    I Javascript? and the syntax please...

    Here is the script I am using:

    <script language="javascript">
    //Display Mouse coordinates- By Kous (kous@ihateclowns.com)
    var where = ""; // which link
    function checkwhere(e) {
    if (document.layers){
    xCoord = e.x;
    yCoord = e.y;
    }
    else if (document.all){
    xCoord = event.clientX;
    yCoord = event.clientY;
    }
    else if (document.getElementById){
    xCoord = e.clientX;
    yCoord = e.clientY;
    }
    self.status = "X= "+ xCoord + " Y= " + yCoord;
    }
    document.onmousemove = checkwhere;
    if(document.captureEvents) {document.captureEvents(Event.MOUSEMOVE);}

    </script>

    Are the variables held in "xCoord" and "yCoord" ?
    How do I post those variables to the next page?

    Thanks
    Gerard
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    you may use document.write() to print the variable on screen(ie, document.write(xCoord ).but for passing this variable to php or any other server side scripts,you may need to pass this variable to a hidden field(eg:input box) and then from there you have to submit to php.You may not be able to pass variable directly to server since the java script is working from client side.
    SR -
    webshiju.com
    www.lizratechnologies.com

    "The fear of the LORD is the beginning of knowledge..."

IMN logo majestic logo threadwatch logo seochat tools logo