onKeyUpHandler - new input

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
gui_calabria
Posts: 5
Joined: February 3rd, 2011, 5:05 am

onKeyUpHandler - new input

Post by gui_calabria »

I'm having the following problem: I use the javascript function bellow to manage the key up function. The problem is when I re-create an input with the same id the Firefox gets the last input value.
You can use the script on http://pastebin.com/7isVQ6Vm to try, just press the button "Novo input" press something check the value printed press the button again and try a new value check what happens.
Is there a way to totally erase a input? I already tried the javascript delete function... checked the settimeout return do clean but nothing worked.


function onKeyUpHandler(campo, funcao, tempo,paramentro)
{
var searchTimeout;
campo.onkeyup = function (event)
{
var tecla = (window.Event) ? event.which : event.charCode;
if (typeof searchTimeout != "undefined") clearTimeout(searchTimeout);
if (typeof paramentro == "undefined") paramentro = "";
else{var string = new String(paramentro);
if (string.substr(0,1)!=',') paramentro = ",'"+paramentro+"'"; }
searchTimeout = setTimeout(funcao+"("+campo.id+","+tecla+paramentro+")", tempo);
};
}
User avatar
malliz
Folder@Home
Posts: 43796
Joined: December 7th, 2002, 4:34 am
Location: Australia

Re: onKeyUpHandler - new input

Post by malliz »

Is this for a web page or an extension?
What sort of man would put a known criminal in charge of a major branch of government? Apart from, say, the average voter.
"Terry Pratchett"
gui_calabria
Posts: 5
Joined: February 3rd, 2011, 5:05 am

Re: onKeyUpHandler - new input

Post by gui_calabria »

web page
User avatar
DanRaisch
Moderator
Posts: 127247
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: onKeyUpHandler - new input

Post by DanRaisch »

Moving to Web Development.
Dom1953
Posts: 52
Joined: July 24th, 2014, 6:02 am
Location: Australia

Re: onKeyUpHandler - new input

Post by Dom1953 »

Unable to reproduce the problem in Firefox 35.0.1
After I click < Novo Input > and type "123", < Novo Input > and type "345", < Novo Input > and type "456", I get
[object HTMLInputElement]|51
[object HTMLInputElement]|53
[object HTMLInputElement]|54
123
345
456
as expected from the code. Have I misunderstood some part of the problem or are you testing with an older version of Firefox?

Personally I remove text filled in by Firefox when it considers a form element dirty after reload by setting the value property, of the input element, to the empty sting ("") after page load.
gui_calabria
Posts: 5
Joined: February 3rd, 2011, 5:05 am

Re: onKeyUpHandler - new input

Post by gui_calabria »

Hi,
I got the problem on previous version.
Thank you!
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: onKeyUpHandler - new input

Post by patrickjdempsey »

Which "previous version" exactly?
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
Post Reply