Frage

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.

War es hilfreich?

Lösung

Try this..

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

or

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

Andere Tipps

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

document.getElementById('pricingConsumerVat').innerHTML = x.value; 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top