[thelist] DHTML questions...

The Optimizer chrism at puffofsmoke.net
Thu Nov 15 08:05:34 CST 2001


Janice

[..]
> First question - how to use a function to set variables. I have the
> following set up as a function -
>
> function locateBox(top_loc,left_loc)
>     {
>     return top_loc;
>     return left_loc;
>     }

First point, you need to understand variable scope.  These are local
variables, their scope being within the function only.

> When clicking an image, I want to update the top_loc & left_loc variables
> using:
>
> onclick="locateBox(50,90)"

In order to relocate the div dynamically, you will have to write/use a
cross-browser wrapper, and then manipulate the div through the Document
Object Model (DOM). Unfortunately the DOM is different for different
browsers, hence the need for the wrapper.

> This should update a <div> style with the appropriate numbers and move my
> box on the map using the following:

You should hard-code the div tag initially unless there is a compelling
reason not to. Then use the DOM to change the CSS properties.

> Now, second question - even should I get this working, am I
> headed down the
> wrong path??? Take a look at

Utterly, IMHO. I would suggest getting someone else to do it if there are
time constraints, or dedicating some time and resources to actually learning
JavaScript and CSS from scratch. A good beginner's book is "JavaScript for
the WWW" on Peachpit Press (http://www.peachpitpress.com). They also do a
CSS book for beginners. These books are more or less disposable; they will
not serve for reference, but they may kickstart you in the right direction.
As far as dHTML goes, it is more a term for the interaction between HTML,
CSS and JavaScript than an actual technology in its own right.

> http://averra.com/mstest/testing_3.htm
>
> which is using javascript to create the <div> tag - works fine 'n dandy in
> Explorer, but not in Netscape (v4.7) - why, oh why??? This works
> in Netscape
> with standard html but now when generated with javascript.

Not that I've checked, but I would imagine that the reason for this is that
NS 4.7 does not support the writeIn method, FWIW.

HTH

Chris Marsh





More information about the thelist mailing list