Changing text on a page dynamically

Discussion in 'JavaScript' started by KS63, Mar 27, 2007.

  1. #1
    Greetings,
    I'm dynamically displaying a picture on a page and I would like to display a pattern ID (text) directly above or under the picture.

    I have the text in a variable that I need, but how do I change the text under/above the picture? I guess I could put a text box under/above the picture and update it's value.

    Thanks in advance,
    Kevin
     
    KS63, Mar 27, 2007 IP
  2. Adi

    Adi Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should use innerHTML to change that test, this is done by:

    1. Get a "pointer" to the HTML element you want to change (let's say it is a div)
    2. You set the innerHTML to the new value.

    example:

    HTML
    <div id="PatternID"> 111 </div>

    JS
    var obj = document.getElementById("PatternID");
    if (obj != null)
    obj.innerHTML = "222";

    You can find more info at: http://www.w3schools.com/htmldom/met_doc_getelementbyid.asp
     
    Adi, Mar 27, 2007 IP
  3. KS63

    KS63 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Excellent - thanks for the help!
    This forum is awesome.
    Kevin
     
    KS63, Mar 27, 2007 IP