SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to show diffrent data inside a div

    Hi at the moment I have some functions that recievs a variable


    for example

    Code:
    
    
    function handleName(var){
    ???
    }
    
    function handleModules(var){
    ???
    }
    I also have the following html code


    Code:
    <a href="javascript:handleName(nameExample);">Show Name</a>
    
    <a href="javascript:handleModules(57);"> Show number of modules</a>
    
    <div id"Show data here"> I want the data to be showed here</div>

    I want the functions handleModules and handleNames to print out the variable that it recieves in the div with the id "Show data here", and the old data that was inside that div previously must dissapear to make room for the new data.

    I must do this in javascript, so does anybody have an idea on how to accomplish this?

    Thanks again for a great forum

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    The simplest version would be something like this (assuming your DIV has the id 'show'):

    Code:
    function handleName(var){
        document.getElementById('show').innerHTML = var;
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •