# Changing label text using javascript



## whoopy_whale (Jun 7, 2007)

Please suggest me a way to change a label text using javascript.
I have a form with some input elemnts in it.
Whenever the user makes an input into a particular text field,that input should reflect as the text inside the <label> tag...

How can I do it?
Help plz...


----------



## lywyre (Jun 8, 2007)

Here it is. The value will be updated after the focus is moved away from the text box. [onblur() also has the same effect]

<form>
<label id="mylabel">No text</label>
<br /><input size="15" id="mytext" onchange="updatelbl()"/>
<br /><input size="15" />
</form>

<script type="text/javascript">
function updatelbl(){
document.getElementById("mylabel").innerHTML = document.getElementById("mytext").value;
}
</script>


----------



## whoopy_whale (Jun 18, 2007)

Thanx buddy...


----------

