/    Sign up×
Community /Pin to ProfileBookmark

onclick code in location

Hello!
I’m working on dynamic tree, based on xtree2. I wanted to add onclick to tree nodes and it was working fine, but suddenly it stop to work. The problem is that when I click on the node, the code from onclick appears in location bar of browser and instead of expected page, I see ‘true’ (result of script) in browser window.

The static code

[CODE]<a href=”#” onclick=”javascript:loadform(‘customers/edit/cust1’);”>cust1</a>[/CODE]

works fine, but dynamically generated code:

[CODE]
<a href=”#” class=”webfx-tree-item-label” tabindex=”-1″ onclick=”javascript:loadform(‘customers/edit/cust1’);”>cust1</a>
[CODE]

does not work. What I’m doing wrong ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 16.2010 — [CODE]<a href="#" class="webfx-tree-item-label" tabindex="-1" onclick="loadform('customers/edit/cust1'); return false;">cust1</a>[/CODE]
Copy linkTweet thisAlerts:
@jarek333authorNov 17.2010 — After number of experiments, I've found, that the problem was really related to return value of onclick function.

If the function in onclick, returns value, it works properly in static html. In dynamic function returning value is not working - confirmed in Firefox and Opera.

In dynamic html function in onclick must NOT have return statement to work.

It is not clear form me why it works like this
×

Success!

Help @jarek333 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 6.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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...