Avatar of Graeme McGilvray
Graeme McGilvray
Flag for Australia asked on

Want collapsed, not expanded as default

Hi all, I am having some issues with expand/collapse and wondering if anyone can help

The issue I am having is it is auto expanded, where I want it collapsed

You can see here: http://dev.gptouring.com.au/home.asp?c=35&p=1&d=80

VBScript
function Expand(node)
	{
	if (node.children.length > 0)
		{
		if (node.children.item(0).tagName == "IMG")
			{
			node.children.item(0).src = "http://www.gptouring.com.au/images/GPT/s-collapse.png";
			}
		}
	node.nextSibling.style.display = '';
	}

function Collapse(node)
	{
	if (node.children.length > 0)
		{
		if (node.children.item(0).tagName == "IMG")
			{
			node.children.item(0).src = "http://www.gptouring.com.au/images/GPT/s-expand.png";
			}
		}
	node.nextSibling.style.display = 'none';
	}

function Toggle(node)
	{
	if (node.nextSibling.style.display == 'none')
		// Unfold the branch if it isn't visible
		{
		Expand(node);
		}
	else
		// Collapse the branch if it IS visible
		{
		Collapse(node);
		}
	}

Open in new window

Code:
<td height=15 colspan=4><a onClick='Toggle(this)' id='CorporateStaff' style='CURSOR: hand'><img src=http://www.gptouring.com.au/images/GPT/s-collapse.png height=15 valign=middle>&nbsp;<font size=2>Expand to upgrade your <%=PackageItemHeroType("itype_name")%></font></a>
<div>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td height=40><%=ItemOptionDisplayName%></td>
<td height=40 width=72 align=center valign=center>
<table width=72 height=36 cellpadding=0 cellspacing=0 border=0>
<tr>
<td height=36 background=<%=BrandDir%>/item-<%=PackageItemOption("prod_items.item_ID")%>.jpg style='background-size:cover;background-position: center,center'><a href=images/GPT/image.jpg><img src=<%=BrandDir%>/s-i-outline-zoom.png width=72 height=36></a></td>
</tr>
</table>
</td>
<td height=40 width=50 align=center><input type=radio name=<%=PackageItemOption("pitem_ID")%> value=<%=PackageItemOption("pitem_gross")/PackageItemOption("pitem_pax")%>></td>
<td height=40 width=150></td>
</tr>
</table>

Open in new window

ASP

Avatar of undefined
Last Comment
Chinmay Patel

8/22/2022 - Mon
Chinmay Patel

Hi Graeme,

Both the nodes have CorporateStaff as their id. Please give them a unique id, in fact, every element on the page must have a unique id.
Assuming you change their ids to CorporateStaff1 and CorporateStaff2

Please add this code snippet after the closing body tag.
<script type="text\javascript">
Toggle(document.getElementById('CorporateStaff1'));
Toggle(document.getElementById('CorporateStaff2'));
</script>

Open in new window

Regards,
Chinmay.
Graeme McGilvray

ASKER
The Code, I copied off another site.

I have added your code after the </body> tag (at the bottom of the page), no change

Also the toggle is a in a SQL Loop, so adding a number to the end I dont think is possible

Thoughts?
Chinmay Patel

Please share the code of the loop. And you meant to say SQL or ASP loop?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Graeme McGilvray

ASKER
Sorry yes, ASP Loop

Set PackageItemOption=oConn.Execute("SELECT * FROM prod_items,items WHERE prod_items.item_ID=items.item_ID AND pitem_live=TRUE AND dep_ID="&Request.QueryString("d")&" AND NOT pitem_ID=pitem_alt AND pitem_alt="&PackageItemHero("pitem_ID")&" ORDER BY pitem_pax,pitem_gross")
If NOT PackageItemOption.EOF Then
	MainArea=MainArea&"<tr>"
	MainArea=MainArea&"<td height=15></td>"
	MainArea=MainArea&"<td height=15 colspan=4><a onClick='Toggle(this)' id='CorporateStaff' style='CURSOR: hand'><img src=http://www.gptouring.com.au/images/GPT/s-collapse.png height=15 valign=middle>&nbsp;<font size=2>Expand to upgrade your "&PackageItemHeroType("itype_name")&"</font></a>"
	MainArea=MainArea&"<div>"
	MainArea=MainArea&"<table width=100% cellpadding=0 cellspacing=0 border="&BorderOnOff&">"
	Do Until PackageItemOption.EOF
	MainArea=MainArea&"<tr onMouseOver=ChangeColor(this); onMouseOut=UnChangeColor(this);>"
	MainArea=MainArea&"<td height=40>&nbsp;&nbsp;&nbsp;&nbsp;"&ItemOptionDisplayName&"</td>"
	MainArea=MainArea&"<td height=40 width=72 align=center valign=center>"
	MainArea=MainArea&"<table width=72 height=36 cellpadding=0 cellspacing=0 border="&BorderOnOff&">"
	MainArea=MainArea&"<tr>"
	MainArea=MainArea&"<td height=36 background="&BrandDir&"/item-"&PackageItemOption("prod_items.item_ID")&".jpg style='background-size:cover;background-position: center,center'><a href=images/GPT/image.jpg><img src="&BrandDir&"/s-i-outline-zoom.png width=72 height=36></a></td>"
	MainArea=MainArea&"</tr>"
	MainArea=MainArea&"</table>"
	MainArea=MainArea&"</td>"
	If PackageItemOption("pitem_sold")=TRUE Then
		MainArea=MainArea&"<td height=40 width=200 align=center colspan=2><b><font color=red>SOLD OUT</font></b></td>"
	Else
		MainArea=MainArea&"<td height=40 width=50 align=center><input type=radio name="&PackageItemOption("pitem_ID")&" value="&PackageItemOption("pitem_gross")/PackageItemOption("pitem_pax")&"></td>"
		MainArea=MainArea&"<td height=40 width=150></td>"
	End If
	MainArea=MainArea&"</tr>"
	PackageItemOption.MoveNext
		Loop
End If

Open in new window

Chinmay Patel

No worries.

Your code is not the complete page and I do not have any means to test ASP 3.0 code, so we might have to do some trial and error.
Please replace line 6 from your above code snippet with this one
MainArea=MainArea&"<div style='diplay:none'>"

Open in new window


Please remove the JavaScript I posted earlier from your page.

Regards,
Chinmay.
Graeme McGilvray

ASKER
I have removed the JS and amended the line, no difference

I did post the whole page, simply because it is over 1000 lines

Regards
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Chinmay Patel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Graeme McGilvray

ASKER
Thank you Chinmay! works a treat! :)
Chinmay Patel

Glad I could help.