Jump to content

clear <div> element


Rominall
 Share

Recommended Posts

I've got a webpage that pulls some XML tables. And at the top I want to have the user choose which page to load. the buttons work as is but if the buttons are clicked more than once the div that get's populated multiplies. So if they click button 1 then button 2 and button 2 and button 1 I get 4 tables on down the page.What I want to do is to clear the <div> element if it's not blank. Here's part of my function (duplicated for both buttons):

function displayResultPS() {

if (document.getElementById("example").value !=""){
document.getElementById("example").innerHtml = "";
}
...code that loads XML table that works
}
here's the HTML for the buttons and div:
<input name="HC" id="HC" type="button" value="HC" onclick="displayResultHC()">
<input name="PS" id="PS" type="button" value="PS" onclick="displayResultPS()">
<div id="example" />

 

Why doesn't it work???

Link to comment
Share on other sites

if (document.getElementById("example").innerHTML!=""){    document.getElementById("example").innerHTML = "";

...and I don't really see any need for the if statement.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...