Jump to content

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...