• CONTEST ALERT - Experience the power of DDR5 memory with Kingston Click for details

Changing label text using javascript

Not open for further replies.


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...


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

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

<script type="text/javascript">
function updatelbl(){
document.getElementById("mylabel").innerHTML = document.getElementById("mytext").value;
Not open for further replies.
Top Bottom