I wanted to know how I can call a function through a text box. example:
<input type="text" value="load()"/>
But it's not exactly the load function, I wanted the digitizer to call any function itself.
I wanted to know how I can call a function through a text box. example:
<input type="text" value="load()"/>
But it's not exactly the load function, I wanted the digitizer to call any function itself.
You can use eval () . Try this:
var input = document.querySelector('input[type=text]');
input.addEventListener('blur', function(){
eval(this.value);
});
But I highly recommend read this about eval ();
All objects defined via direct code at the root of the scope will stop at the object window
, so you can do this:
window["nome do método"]();
This will call the function you want by name.
Just use the attributes of type onevent
of tag input
.
For example:
<input type="text" onkeydown="alert('keydown')" />