Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change a DIV's content using JavaScript

Status
Not open for further replies.

denektora

Programmer
Jul 19, 2010
1
BG
Hi,
I'm currently working on a webpage and I want to have an HTML index page with a "content" DIV whose content I control using a menu of clickable buttons. It has six buttons that once clicked should load six different .php's in the div. Each php will contain its own "submenu" that load secondary content in the php's "content2" DIV. I seem to have taken care of the second part, but the first one refuses to work. Clicking one of the menu buttons initially works, but clicking another button leads to nothing. Here's a link to what I've done so far. (If anyone has a ready script for a similar operation, please give me a hand. Thanks in advance!
 
to change the content in a DIV simply make sure the DIV has a unqiue ID and use...
Code:
document.getElementById('myID').innerHTML = '<h3>This is a heading</h3>';

or if you have the HTML stored in a variable...
Code:
document.getElementById('myID').innerHTML = myVar;

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top