/    Sign up×
Community /Pin to ProfileBookmark

problem with removeEventListener

Dear members

i have this part of code in some jsp file

[CODE]
<td><input type=”text” [b]id=”preciounitarioventa” [/b]
value=”${articulo.precioUnitario}” size=”15″
[b]onfocus=”blanquearcampo(‘preciounitarioventa’)”[/b]
onblur=”redondear2decimalessalidacampo(‘preciounitarioventa’)” />
</td>
[/CODE]

where in an extern .js file (ie a.js)

[CODE]
//onfocus=”blanquearcampo(”)”
function blanquearcampo(idtag){
document.getElementById(idtag).value=””;
}
[/CODE]

the problem is in another extern .js (b.js)
i wrote

[CODE]
document.getElementById(“preciounitarioventa”).value=”TEST”;
[b]document.getElementById(“preciounitarioventa”).removeEventListener(‘onfocus’,blanquearcampo,false);[/b]
document.getElementById(“preciounitarioventa”).setAttribute(“readOnly”,”true”);
[/CODE]

well the console, doesnt throw some error, but when i try to do click in the
field, the onfocus event still work , the value of the field is gone and now
readonly works really

what is wrong with my code in [B]removeEventListener[/B]

thanks in advanced

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 24.2008 — Not fully supported
document.getElementById("preciounitarioventa").removeEventListener('[COLOR="SeaGreen"]focus'[/COLOR],blanquearcampo,false)
Simpler
document.getElementById("preciounitarioventa").onfocus=null;
Copy linkTweet thisAlerts:
@mrhooApr 24.2008 — removeEventListener removes an event handler that was applied with addEventListener.

It won't remove anonymous functions, and the arguments have to match those used to add the handler.
×

Success!

Help @dr_pompeii 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.23,
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,
)...