View Single Post
Old 04-23-2007, 04:07 PM   #2 (permalink)
exam
Senior Member
 
exam's Avatar
 
Join Date: 04-20-06
Posts: 278
iTrader: 0 / 0%
Latest Blog:
None

exam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web proexam is a highly respected web pro
The right way to do this would be using the DOM to add and remove nodes, but here's a hack that should do it for you. You're basically removing the contents of the div every time you hide the div, and put the contents back every time you show it. When you copy and paste, and extra line will be there, since the HTML element is still there, it's just empty. This can be sidestepped by using an element that is an inline element by default.

Code:
<html><head> <script type="text/javascript"> var g_details_data = Array(0); g_details_data['details1'] = 'some info<br>more info<br>etc 1<br>'; g_details_data['details2'] = 'some info<br>more info<br>etc 2<br>'; function toggle(obj) { var el = document.getElementById(obj); if (el.style.display != 'none') { el.style.display = 'none'; el.innerHTML = ''; } else { el.style.display = 'block'; el.innerHTML = g_details_data[obj]; } } </script> </head> <body> <span onclick="toggle('details1')">the numbers for this stat is: 1234</span><br> <span id="details1" style="display:none"></span> <span onclick="toggle('details2')">the numbers for this stat is: 5678</span><br> <span id="details2" style="display:none"></span> </body></html>
exam is offline   Reply With Quote