Javascript and motion

They have: 330 posts

Joined: Apr 2000

I am trying to learn some motion for javascript and am not having much luck.

Here is the code I'm working with.

<?php
<!--
function
moveit(spot)
    {
    var
picture=document.all.image1.style;
    if (
spot<100)
        {
           
picture.top= spot;
           
spot+=5;
           
setTimeout('moveit('+spot+')',100);
        }
    }
//->
...
<
A HREF=\"javascript:moveit(10)\">Move</A>
?>

I know that I can change picture.top to picture.left and it will make it move right to left and spot+=5 to spot-=5 to move the other direction. How do I ask it to move from point a to point b the first time it's clicked, point b to point a the next time, and so on?

How do I set the numbers to change instead of it being 100 all of the time?

Here's what tried to set different variables... it didn't work.

<?php
<!--
function
moveit(spot, stop)
    {
    var
picture=document.all.image1.style;
    if (
spot<stop)
        {
           
picture.top= spot;
           
spot+=5;
           
setTimeout('moveit('+spot+')',100);
        }
    }
//->
...
<
A HREF=\"javascript:moveit(10, 100)\">Move</A>
?>

Thanks for any help.

detox's picture

They have: 571 posts

Joined: Feb 2001

Whenever I am doing anything with javascript like this I use the dhtmlLib v2.1 from here dhtmlLib v2.1 or dynlayer from here: dynlayer . it has great documentation and basically has everything I need. Check it out. I used to think I was being lazy with this until I started using com for ASP and an extensive base functions include file.

Do you want the user to specify the amount of movement? What is the context of the movement? i.e how are you using it?

They have: 330 posts

Joined: Apr 2000

At this point I'm just trying to learn how to do it so I can apply it however I need in the future. The initial project I'm testing it on is somewhat of an ASP briefcase which has a list of folders, subfolders, and files. It will hide all subfolders and files until otherwise requested. Once requested they will be displayed. I have this working through straight ASP and querystrings to decide which files are shown but that opens the database and closes it for each request.

I'm sure if I can learn this is will be a lot better on the server and easier to manipulate later because of the ASP I will be able to delete for these calculations.

They have: 330 posts

Joined: Apr 2000

I have used this forum before and I know there are some very brilliant people that answer questions here. Now I know one of you know how to make a menu scroll down instead of immediately drop down and vice versa.

Has anyone here built a DHTML menu before? Does anyone know of a DHTML tutorial which will show me how to create one from scratch?

Thanks for any help.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Or perhaps the DHTML books?

htmlguru.com

hth,

Suzanne

They have: 330 posts

Joined: Apr 2000

I will search a little more but I was already at htmlguru.com earlier today and I left because all I could find was something about an eye before I got a headache. I kept using the mouse's wheel hoping to scroll (out of habit of course) and the screen just bounces which is terrible.

I'm sorry if the owner or developer is reading this. I'm sure it's a great site.

detox's picture

They have: 571 posts

Joined: Feb 2001

Here is a webmonkey tut i just found on the subject:buid menu

There are many different ways to skin a cat though. If you are usin ASP for this, then maybe even check this link out, it's a tut about asp driven dhtml menubars:asp driven menu

When you want to learn something in DHTML javacript etc, the best way is often to look at the coding of a site you like. Try and figure it all out. Of course that can be very daunting, but you learn more....

They have: 330 posts

Joined: Apr 2000

I will check those tutorials out, thank you.

I have tried to download some pre-made menus and study them and they kind of made sense but seemed like a lot more than I need. I tried stripping them but that didn't work. I'm sure one of these tutorials will let me learn how to create them from scratch or at least answer some of my questions. Thank you again.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.