Try this..
document.getElementById('pricingConsumerVat').textContent = x.value;
or
document.getElementById('pricingConsumerVat').innerHTML = x.value;
Pregunta
I have a dropdownlist and I want that when my document is loaded the value currently selected in the dropdown be in the label.
I have a script as
var x = document.getElementById('vatRate');
document.getElementById('pricingConsumerVat').textContent = x;
I get the value in the variable x, however I am not able to display the same in my label.
Why so ?
My label is as
<label id="pricingConsumerVat"></label>
Any jQuery solutions is most welcomed too.
Solución
Try this..
document.getElementById('pricingConsumerVat').textContent = x.value;
or
document.getElementById('pricingConsumerVat').innerHTML = x.value;
Otros consejos
var x = document.getElementById('vatRate');
document.getElementById('pricingConsumerVat').innerHTML = x.value;