/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] calling a function from inside another function

Hi,

I am working on a google map where you can show lines on the map by checking checkboxes. Lines are displayed according to their category attribute in the xml file. The function that picks up the checkbox click is like this:

[CODE]
function boxclick(box,category) {
if (box.checked) {
show(category);
} else {
hide(category);
}[/CODE]

Another part of the code assigns that category attribute to arrows, so that when a line of “x” category is displayed, the relevant arrows are displayed along with it, to indicate directionality.

I also have a select list which displays the lines by looping through their array and using selectedIndex in a function called handleSelected2. But I can’t get the arrows to display along with the lines from the select box. After trying many, many things, I figure that all I need to do is to call the show(category) function from inside the handleSelected2 function and it should all come together. So I came up with this:

[CODE]function handleSelected2(opt,category) {
for (var h = 0; h <gpolylines.length; h++) {
gpolylines[h].hide();
}
var h = opt.selectedIndex – 1;
if (h > -1) {
gpolylines[h].show();
}
for (var v=0; v<pts.length; v++) {
show(category);
}
}
[/CODE]

which gets me lines, but no arrows. You can see it sort of working here:
[URL=”http://www.xelawho.com/map/zonesarrowstest.htm”]http://www.xelawho.com/map/zonesarrowstest.htm[/URL]

I figure I’ve got to be close, because if I just tell it to show all the arrows (without going through the category filter) like this:

[CODE]function handleSelected2(opt,category) {
for (var h = 0; h <gpolylines.length; h++) {
gpolylines[h].hide();
}
var h = opt.selectedIndex – 1;
if (h > -1) {
gpolylines[h].show();
}
for (var i=0; i<pts.length; i++) {
pts[i].show();
}
}[/CODE]

then all the arrows show up, as you can see here: [URL=”http://www.xelawho.com/map/zonesarrowstest2.htm”]http://www.xelawho.com/map/zonesarrowstest2.htm[/URL]

I’m not getting any error messages and I’ve tried pretty much everything I can think of… I’ve been tweaking this for days and it’s driving me crazy. Does anybody else have any ideas?

Thanks in advance.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 24.2010 — At a first glance I see something:
<i>
</i>for ([COLOR="Blue"]var[/COLOR] h = 0; h &lt;gpolylines.length; h++) {
gpolylines[h].hide();
}
[COLOR="Red"]var[/COLOR] h = opt.selectedIndex - 1;


Using the token [B]var[/B] for the same variable more than once brings errors. Once a variable is set it should be referred later (particularly within the same scope) without the token [B]var[/B]
Copy linkTweet thisAlerts:
@xelawhoauthorNov 24.2010 — Thanks for that, Kor. I am (obviously) quite new to this, so every piece of info helps.

removing the var doesn't seem to have helped with the issue at hand, though...
×

Success!

Help @xelawho 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.16,
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,
)...