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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Horizontal or vertical???

    Hi,
    I am a novice trying to learn javascript in depth. I have created a page where in the user can move a image and rotate it accordingly by clicking on the rotate button and the user will place this image on the browser.gif image. As and when the user moves the image, the coordinates X and Y will be entered into the text box as seen in this page. http://www21.brinkster.com/sashwin/s...oriorvert.html ( works only in IE). The user can click on the rotate button to position it vertically.

    When the user hits the submit button, I need to know whether the user rotated the image or not. I mean whether it was placed horizontally or it was placed vertically on the browser.gif image. Also, how do I go about in the coding so that the movement and the rotation works in Netscape too.

    Thanks a lot for your time.

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    put this in ur global vars
    var Direction=true;


    put this in ur rotate() function or in the onclick event for the button:
    Direction=!Direction;

    put this where u wanna check what direction it is in
    if(Direction)
    {
    alert('Horizontal');
    }
    else
    {
    alert('Vertical');
    }

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot. It's working. When the user places it vertically instead of "alert" I used document.myform.adver.value = "Vertical"; so that vertical will be inserted into the textbox and accordingly for horizontal document.myform.adhor.value = "Horizontal";. This is what I had modified. I have done this because I will be passing these values to a script and in turn to a database.

    var image1

    image1=!image1;

    if(image1)
    {
    document.myform.adhor.value = "Horizontal";
    }
    else
    {
    document.myform.adver.value = "Vertical";
    }
    }

    In the above code if the user FIRST places it vertically then the "Vertical"would be entered into the relevant textbox. But if the user changes his mind and rotates it again the code would enter "Horizontal" into the relevant box.

    At this point I would not know whether he placed the vertically or horizontally as both "vertical" and "horizontal" would have been entered. The code which you had written was perfect but I dont want the alert button to be displayed. How do I fix this issue. I need the last position value to be inserted into the textbox. I hope that i was clear in my query. This link might be more clearer.

    http://www21.brinkster.com/sashwin/s...iorvermod.html

    Thanks again

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Simply use one text field.

    if(image1)
    {
    document.myform.adpos.value = "Horizontal";
    }
    else
    {
    document.myform.adpos.value = "Vertical";
    }

  • #5
    New Coder
    Join Date
    Jan 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh!!! thanks a lot. Such a simple thing. Thanks for your time.


  •  

    Posting Permissions

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