Rominall 0 Posted May 6, 2014 Report Share Posted May 6, 2014 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??? Quote Link to post Share on other sites
davej 251 Posted May 6, 2014 Report Share Posted May 6, 2014 if (document.getElementById("example").innerHTML!=""){ document.getElementById("example").innerHTML = ""; ...and I don't really see any need for the if statement. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.