javascript update textbox - error

0
Hi, I have a javascript that runs and in the end I would like to update a textbox that I have with the javascript result. But when I run the following javascript: document.getElementById('textBox1').value = resultVal;  I get “TypeError: Cannot set property 'value' of null”.   Thanks for help!   kr Thomas  
asked
1 answers
0

Apparently “document.getElementById('textBox1').value “ return nothing.

from my own experience, this is way more easy to retrieve a element with a class name using jquery, like that : 

var resultVal = “some text”; 

$('.MyClass').text(resultVal);

 

or if it’s an input (textbox) : 

 

var resultVal = “some text”; 

$('.MyClass input').val(resultVal);

 

Sometimes also the javascript snippet is loaded before the element, and therefore does not found your element ( if it’s happening you can try to move your javascript snippet or add a set time out function).

answered