...

View Full Version : Horizontal or vertical???



ashwin
01-13-2004, 12:33 AM
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/survey/horiorvert.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.

Garadon
01-13-2004, 01:37 AM
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');
}

ashwin
01-13-2004, 03:12 AM
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/survey/horiorvermod.html

Thanks again

glenngv
01-13-2004, 03:59 AM
Simply use one text field.

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

ashwin
01-13-2004, 05:56 AM
Oh!!! thanks a lot. Such a simple thing. Thanks for your time.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum