Reputation: 47530
I've two separate HTML file and .js file. I have a calculate method which return the result in the Javascript file.
My question is how to set a textbox value from a Javascript return value. Or at least from a separate Javascript file. Initially I tried below which doesn't work as Javascript and html are separated.
function Calculate(ch)
{
//...
document.getElementById('Input').value = resultValue;
}
Upvotes: 2
Views: 24698
Reputation: 47530
eval is the soution for my problem. Input.value = eval(Calculate(ch))
Upvotes: 1
Reputation: 5589
Access textarea contents using the innerHTML
property, not the value
property.
function Calculate(ch) {
//...
document.getElementById('Input').innerHTML = resultValue;
}
Upvotes: 0
Reputation: 2707
try to define the js-file in the bottom of your html-file (near the </body>). if you defined it above the targeted element its unknown. this may help.
felix
Upvotes: 0