PDA

View Full Version : Using Span with InnerHTML


Shevy
04-14-2004, 04:14 PM
I am trying to write an HTML page which looks like windows explorer. There are folders and subfolders and in the subfolders there are documents. You are able to click on the folder and expand and collapse it. I have it all working perfectly using spans and innerHTMLs. However there is one part which is not working and I cant seem to figure out why. when i click on the category to display the subcategory, the subcategory doesnt show up. nothing happens - no error.. when i messagebox the innerHTML it cuts off part of it. Here is a snippet of code:


<table><tr><td size=175><a href='VBScript:toggleTree(1,"Closing")'><img src=icons\minus.gif id=mp1 border="0"></a><a href='VBScript:toggleTree(1,"Closing")'><img src=icons\folderopen.gif id="img1" border="0" ></a>Closing</td></tr>
<span id="div1"><tr><td size=175> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href='VBScript:toggleTree(0,"CLSCOR")'><img src=icons\plus.gif id="mpCLSCOR" border="0" ></a> <a href='VBScript:toggleTree(0,"CLSCOR")'><img src=icons\folder.gif id="imgCLSCOR" border="0" ></a>Correspondence</td></tr><tr><td></td><td>
<span id="divCLSCOR"></span>
</td></tr>
</span>
</table>

function toggleTree
text = "<tr><td size=175>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='VBScript:toggleTree(0,""CLSCOR"")'><img src=icons\plus.gif id=""mpCLSCOR"" border=0 ></a><a href='VBScript:toggleTree(0,""CLSCOR"")'><img src=icons\folder.gif id=""imgCLSCOR"" border=0 ></a>Correspondence</td></tr>" _
& "<tr><td></td><td>" _
& "<span id=""divCLSCOR"">" _
& "</span></td></tr>"
divname = "div" & num ( i pass num to the function)
Execute(divname & ".innerHTML = text" )end function

PLEASE HELP. I have been trying to figure this out for some tiime now...

Willy Duitt
04-18-2004, 03:46 PM
Did you find your solution?

If not, the problem most likely lies in the double quotes within the contents of your text variable are conflicting with the double quotes you used to delimit the string.

Try using a backslash (\) to escape all of the double quotes within the text variable contents.

Personally, I find it much easier to delimit all javascript strings with a single quote and all html attributes with double quotes. This greatly reduces the possibility of a conflict and having the string prematurely closed.

.....Willy