View Full Version : document.[name].style.... problem!!

Francisco Dias
11-29-2007, 03:52 PM
i'm developing a menu and I'm having some problems.
I wanted to do a general code move items on a menu.


before after
_______ ________
|_______ |________
|_______ |________
|_______ |________
|_______ |________

it is activated by mouseover, and I wanted to create a function that covered all buttons at once.

function movemenu(x) //x is the name of the img//

document.[x value].style.left =....

but nothing happens!!

Resume: I wanted to call name (or id) as a variable

11-30-2007, 05:13 AM
The preferred method these days is by id:


Or, if used in a function where the id is supplied as x:

function movemenu(x){

Also, units (such as px) must be specified in most browsers for top, left, height, and width (as well as for a number of other style properties). If you are passing the value as a number held in a variable, the units must still be applied:

function movemenu(x, n){

The getElementById method is case sensitive.

Francisco Dias
12-01-2007, 01:40 AM
You rule man!! :D