M
M
Mesuti2018-02-07 17:05:16
JavaScript
Mesuti, 2018-02-07 17:05:16

Instant calculation when entering in input?

Hey!
Tell me , please
1) Why doesn't JavaScript work in the Jsfiddle sandbox ? And it works on regular hosting .
2) How to make sure that when you enter a number in Input, the calculation occurs immediately? now you have to click somewhere else, only after that the calculation goes
Thanks to all who answered!
ps found the answer, but how to integrate it into the calculation script?

<input type="text"> oninput: <span id="result"></span>

var input = document.body.children[0];

  input.oninput = function() {
    document.getElementById('result').innerHTML = input.value;
  };

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mesuti, 2018-02-07
@Mesuti

In general, as usual, I’m looking in the distance, but I don’t see under my nose.
Answer:
Namely, from this
On that
Who helped - like =) I had to listen to a stoned Indian for half an hour.

K
koshiii, 2018-02-07
@koshiii

It can simply be done like this:

<script>
function getValue(val){
блоки вычислений
}
</script>

It is better to write about Jsfiddle here:
https://github.com/jsfiddle/jsfiddle-issues/issues

M
maxsnw, 2018-02-07
@maxsnw

put on the changer

E
evgennikolaevich, 2018-02-07
@evgennikolaevich

If you do not need support for older IEs, hang on the oninput events, the onchange event will not occur on every input, but on loss of focus.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question