1

I have the below script, to show me the number version of the keys that are pressed, but as you can see here in jsfiddle I have no idea, why it is not working in fiddle. But, the I am just trying to have earlier inputs saved, because everytime I pressed a key, the previous number gets deleted and a new numbers corresponding the key pops up.

<script type="text/javascript">
function displayunicode(e){
var unicode=e.keyCode? e.keyCode : e.charCode
document.getElementById("op").innerHTML = unicode;

}
</script>
<form>
<textarea onkeyup="displayunicode(event);" ></textarea>

<div id="op"></div>
</form>
0

2 Answers 2

3

Change document.getElementById("op").innerHTML = unicode; to document.getElementById("op").innerHTML += unicode;

Sign up to request clarification or add additional context in comments.

Comments

2

Use string concatenation (+=):

function displayunicode(e) {
    var unicode = e.keyCode ? e.keyCode : e.charCode
    document.getElementById("op").innerHTML += unicode;
}

DEMO: http://jsfiddle.net/KLV56/1/

Your fiddle was not working because you've added your script to onLoad event (see Figure below) that had hidden your function inside it. Use no wrap instead.

3 Comments

how come a 41k bothers answering this one :D . it's not silly but noobs want some reputation you know what i mean :)
@FrozenFlame Ahahah :D Believe or not, even 150k+ need the damned reputation ;)
@FrozenFlame spmetimes it is not about the reps you know, it is also about helping people out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.