Question

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.

Was it helpful?

Solution

Try this..

document.getElementById('pricingConsumerVat').textContent = x.value;

or

document.getElementById('pricingConsumerVat').innerHTML = x.value;

OTHER TIPS

var x  = document.getElementById('vatRate'); 

document.getElementById('pricingConsumerVat').innerHTML = x.value; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top