/    Sign up×
Community /Pin to ProfileBookmark

Function containing other functions – not working

Hello!

I have a problem with Javascript.

I have an element that has to do some things onClick. I was googling how to put few functions into one function and then call main function, like this:

[CODE]
function example()
{
function_one();
function_two();
function_three();
}
[/CODE]

This doesn’t work. Only first function does work on click … other don’t. Then I tried even this:

[CODE]
<img src=”…” onClick=”function_one(); function_two(); function_three();”>
[/CODE]

And again it doesn’t work.

Here is what one function has to do on click:

[CODE]
show(‘layer1’);

show(‘layer2’);

Spry.Effect.Blind(‘cmenu’, {duration: 1000, from: ‘0%’, to: ‘100%’, toggle: true});

body.id=’body2′;
[/CODE]

… where function ‘show’ is:

[CODE]
function show(id)
{
el = document.getElementById(id);
if (el.style.display == ‘none’)
{
el.style.display = ”;
el = document.getElementById(‘more’ + id);
el.innerHTML = ‘less…’;
} else {
el.style.display = ‘none’;
el = document.getElementById(‘more’ + id);
el.innerHTML = ‘more…’;
}
}
[/CODE]

… and Spry.Effect.Blind is from Spry framework:

[url]http://labs.adobe.com/technologies/spry/[/url]

Thank you!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@holyhttpJan 11.2007 — My suggestion would be to start by executing just one function inside your main function then you can move to the next if the result is conclusive.

Also make sure there is a return statement from the inner function say

function show(id){

...

..

..

return true;

}
Copy linkTweet thisAlerts:
@AstroauthorJan 19.2007 — It worked!

Thanks a lot!
×

Success!

Help @Astro spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...