MozillaZine


onKeyUpHandler - new input

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

Post Posted February 18th, 2015, 11:34 am

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);
};
}

malliz
Folder@Home

User avatar
 
Posts: 44213
Joined: December 7th, 2002, 4:34 am
Location: Australia

Post Posted February 18th, 2015, 1:48 pm

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

Post Posted February 18th, 2015, 2:25 pm

web page

DanRaisch
Moderator

User avatar
 
Posts: 124093
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted February 18th, 2015, 2:35 pm

Moving to Web Development.

Dom1953
 
Posts: 52
Joined: July 24th, 2014, 6:02 am
Location: Australia

Post Posted February 19th, 2015, 8:10 pm

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

Post Posted February 22nd, 2015, 3:52 pm

Hi,
I got the problem on previous version.
Thank you!

patrickjdempsey

User avatar
 
Posts: 23734
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted February 22nd, 2015, 4:47 pm

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/

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: Bing [Bot] and 1 guest