Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Move a picture on page by submitting its coordinate

    Hi Guys) Can u suggest me a Jsimple avaScript+CSS for moving an image on the page according to the submitted coordinates in FORM, e.g if I put 60 in Xinput and 100 in Yinput push Submit and a picture will go to that position.
    What model to use...? pixelTop and pixelLeft and how? any ideas... please)
    p.s without php.
    Thanks a lot

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try something like this

    PHP Code:
    <script type="text/javascript"">

    function movePic(){

    newLeft=document.getElementById("
    xinput").value
    newTop=document.getElementById("
    yinput").value

    document.mypic.style.left=newLeft+"
    px"
    document.mypic.style.top=newTop+"
    px"


    }
    </script>


    <img name="
    mypic" src="pic.jpg" style="position:absolute;left:100px;top:100px">

    <input type="
    text" id="xinput">
    <input type="
    text" id="yinput">
    <input type="
    button" value="Move Pic" onclick="movePic()"> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •