So this is my problem I am having an input type , with a default value="monkey" now... i added onKeyPress ... and i am calling a function called detector() ... the problem is this... if somebody press 1... the text will be money1... but if i am doing function detector(){ newurl=document.getElementById("url").value; document.write(newurl); } it will write monkey, even if the last key pressed was 1 and the new text was money1 ...
try onkeypress -> onkeydown / onkeyup, the latter one probably being raised AFTER the concatenation of the string.
watch it in action onkeyup (via mootools) here: http://mooshell.net/YBPBb/ just type in the input field. there is no need to stop the event propagation. the second field is on keypress which is BEFORE the event propagation, it confirms your problem.