473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Stuck for several days

Hello, first of all it's convenient to say that I'm not an expert, neither
nothing similar, just in case. I have been trying to execute this little
piece of code with no results, does anyone there can detect where the bug
is:

var labelsArray = new Array(6);

----------------------------------------------------------------------------
----------------
function objCreation()
{
for (i=0; i < labelsArray.length; i++)
{
var labelObj = {labelID:
"document.getElementById('Label"+i+"').filters.alp ha.opacity"};
labelsArray[i] = labelObj;
}
}

function over(no)
{
eval(labelsArray[no].labelID = 20);
}

----------------------------------------------------------------------------
---------------

Basically, the function objCreation creates 6 objects with only one
attribute (labelID) each one and stores it into an Array called labelArray
Then the function over(no) is loaded when the MouseOver event takes place.
The problem is that since
labelsArray[no].labelID is equal to the string
document.getElementById('Label0').filters.alpha.op acity for example, it is
not recognized as a functional statement, as a result it doesn't do anything
if I assign the value 20 in this case.

The website is at : http://new.vanara.com/ , if someone wants to see it.

Thanks in advance,
Javier.
Jul 20 '05 #1
3 1364
"Javier Troconis" <tr******@telus.net> wrote in message
news:0hmWb.54292$7Q1.9039@clgrps12...
<snip>
var labelsArray = new Array(6); <snip> function objCreation()
{
for (i=0; i < labelsArray.length; i++)
{
var labelObj = {labelID:
"document.getElementById('Label"+i+"').filters.alp ha.opacity"};
labelsArray[i] = labelObj;
}
}

function over(no)
{
eval(labelsArray[no].labelID = 20);
If you are not an experienced javascript programmer and you are using
the - eval - function you can be certain that you are doing something
fundamentally wrong.

<URL: http://jibbering.com/faq/#FAQ4_40 >
}

<snip>

You have omitted one very important detail and that is why. Why jump
through such hoops and use such a convoluted method? When on the face of
it your entire posted code could be replaced with:-

function over(no){
document.getElementById('Label"+no).filters.alpha. opacity = 20;
}

- and achieve your apparent goal in the browsers where it will work.
Or:-

function over(no){
var obj;
if((document.getElementById)&&
(obj = document.getElementById('Label"+no))&&
(obj.filters)&&
(obj.filters.alpha)){
obj.filters.alpha.opacity = 20;
}
}

- Which achieves the same but won't error on the majority of web
browsers in the way the previous version and your original code was
destined to.

Richard.
Jul 20 '05 #2
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c0*******************@news.demon.co.uk...
<snip>
function over(no){
document.getElementById('Label"+no).filters.alpha. opacity = 20; ^ ^
document.getElementById("Label"+no).filters.alpha. opacity = 20;}

<snip>

Except in both cases it will work better with the same type of quote
marks on each side of the string literal.

Richard.
Jul 20 '05 #3
Richard Cornford wrote:
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c0*******************@news.demon.co.uk...
<snip>
function over(no){
document.getElementById('Label"+no).filters.alpha. opacity = 20;

^ ^
document.getElementById("Label"+no).filters.alpha. opacity = 20;
}

<snip>

Except in both cases it will work better with the same type of quote
marks on each side of the string literal.

Richard.


True, that often helps a lot. :P
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ron | last post by:
have been stuck on this for several days now. I am trying to create a reverse polish calculator and I'm stuck at an intermediate stage. This is what I know I have to do (just not sure how to do it...
1
by: jessebasketball | last post by:
i am a very beginner programmer and am stuck on a very simple problem. I am trying to make a game where the user is presented with a scenerio and options. ie you are standing in the parking lot...
2
by: Együd Csaba | last post by:
Hi All, I'm wonder if there is any possibility to kick out automatically stuck in queries after say 10 minutes or so? I mean some kind of queries which calls eg. buggy functions with dead loops...
2
by: sara | last post by:
Hi - I have been trying (for 2 days now) to make some simple surveys (5-7 questions each, each with 2-3 answer choices, always from the list) using Duane's sample. I've searched and searched...
4
by: =?Utf-8?B?TWF1cg==?= | last post by:
My cd is stuck in the drive. I can open the drawer O K but the c d will not come out Help me please -- Maur
11
by: Peted | last post by:
Im using c# 2005 express edition Ive pretty much finished an winforms application and i need to significantly improve the visual appeal of the interface. Im totaly stuck on this and cant seem...
0
by: dodjem | last post by:
Hi all, I have search far and wide for a solution but have been unsuccessful. I have a database table which contains bookings for resources that can be used in our lab and some bookings can...
5
by: Fareast Adam | last post by:
how to add several days to the current date using php? here my php code $time = gmdate('Y-m-d H:i:s a'); what i mean is i want to add 2 days on the current date. how can i do this? your help...
12
by: beatjunkie27 | last post by:
I am working on a class assignment called Pennies for Pay the object of the program is to receive input for number of days worked. This should be > 0 and <= 40. An example output is below and...
2
by: ChipR | last post by:
I'm suddenly having a major problem trying to switch between rows in a continuous form in Access 2007. The form represents a timesheet and has a row for each activity that an employee may work on. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.