Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Set value of html label

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #146592
    kanshul2013
    Participant

    I’m trying to set value of html field using Javascript –

    I’m trying to set value of html field using Javascript –

    HTML

    Javascript document.getElementById(“test”).value = ‘myval’;

    This works fine. Only problem is that the control where value is set, I don’t want it to be an input field but something like a label. Is that possible?

    #146597
    Chromawoods
    Participant

    You mean something like this?

    document.getElementById("test").innerText = 'Whatever';

    Or, if you need to add some HTML to that value:

    document.getElementById("test").innerHTML = 'Whatever makes you <em>happy</em>';

    #146601
    kanshul2013
    Participant

    Thank you, that is what I was looking for.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.