View Full Version : passing a param from a function to another

01-15-2004, 01:39 PM
I have some difficulties to pass a parameter.
I have some objects with same id, so I want to get them by order number let's say they are obj[i].

I call first function on an event onevent="one(0)" in a place, onevent="one(2)" and so on

function one(param){
obj[param].style.attribute ="blabla";
//so far so good, but from now once...

somevariable = setInteval('two(param)',somenumberhere);//here is a mistake, by sure... but which?

function two(param){
//no value passed???
obj[param]... and so on

I need the object in second function as well, but how can I pass the parameter in it?

Any ideeas, please?

01-15-2004, 01:57 PM
I suppose that param is a string. When you pass it to function one, it's only valid inside that function while setInterval executes code outside the functions. So put the value of param in setInterval instead:


01-15-2004, 02:02 PM
No, As I said, it is not a string... Anyway, I tryed, to be sure, the parseInt(param) but no use...:confused: . If I pass a definite number, yes, is OK, but I don't need to pass a certain value, I want to pass a value according to the event handler parameter....

01-15-2004, 02:20 PM
Sorry, maybe I should start reading more carefully :o

Let me first see if I got it now:
You have some elements with the same id, so they become a collection (ie-only?). The elementcollection is global.

So the only difference to what I wrote before would be to remove the double-quotes:


If you call function one:

the setInterval should looks like this at runtime:

Somehow it feels like I didn't understand this time either.

01-15-2004, 02:27 PM
u tried writing:
instead of:

01-15-2004, 02:30 PM
Yeees Sir, I got it... Even it looks strange to me at the first glance to write something like


But I got the sense, thank you

01-15-2004, 04:32 PM
You could always have a look at <http://codingforums.com/showthread.php?s=&threadid=29568#post152688>. It's a method of doing things that might be a little hard to grasp, but it allows you to send things in other formats than as just a string.

01-15-2004, 05:06 PM
tack sa mycket, liorean... I saw that the main problem was not to pass a parameter, but to understand the setInterval() method