CementTruck
asked on
I need help creating onClick Hide Show events.
I've created these functions in the past, but always with static information. This time I a creating a catalog from a DB Table and I will need the page to create the onClick show and onClick hide entries automatically. I use ColdFusion for the queries, but need to know if there is some wildcard I can use in Javascript to get this to work. I hope I explained this properly.
I don't have any code to show since I have no idea where to begin.
I don't have any code to show since I have no idea where to begin.
ASKER
I apologize for the vague example. The code below is more of what I'm looking for. I already have this code working on another page, but need to automate the naming of a function every time a new title is introduced into the database table. I'm almost positive this will require looping the query, but that is a CF question.
Thanks for responding.
-------------------------- ------
function acct()
{
document.getElementById('h ideacct'). style.disp lay = "inline";
document.getElementById('s howacct'). style.disp lay = "none";
}
function accthide()
{
document.getElementById('h ideacct'). style.disp lay = "none";
document.getElementById('s howacct'). style.disp lay = "inline";
}
-------------------------- -----
<DIV ID="show<CFOUTPUT>#rsGetCa t.tag#</CF OUTPUT>" STYLE="display:inline">
<A HREF="#" onClick="<CFOUTPUT>#rsGetC at.Tag#</C FOUTPUT>() " STYLE="text-decoration : none;"><IMG SRC="Images/icon_greencirc le_plus.gi f" BORDER="0"> <CF OUTPUT>#rs GetCat.Cat egory#</CF OUTPUT></A >
<BR><BR></DIV>
<DIV ID="hide<CFOUTPUT>#rsGetCa t.tag#</CF OUTPUT>" STYLE="display:none">
<A HREF="#" onClick="<CFOUTPUT>#rsGetC at.Tag#</C FOUTPUT>hi de()" STYLE="text-decoration : none;"><IMG SRC="Images/icon_redcircle _minus.gif " BORDER="0"> <CF OUTPUT>#rs GetCat.Cat egory#</CF OUTPUT></A ><BR><BR>
</DIV>
Thanks for responding.
--------------------------
function acct()
{
document.getElementById('h
document.getElementById('s
}
function accthide()
{
document.getElementById('h
document.getElementById('s
}
--------------------------
<DIV ID="show<CFOUTPUT>#rsGetCa
<A HREF="#" onClick="<CFOUTPUT>#rsGetC
<BR><BR></DIV>
<DIV ID="hide<CFOUTPUT>#rsGetCa
<A HREF="#" onClick="<CFOUTPUT>#rsGetC
</DIV>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay in responding.
I FIGURED IT OUT!!!
Here's the code -
-------------------------- ---------- ---------- ---------- --------
<cfloop query="CatalogHeader">
<SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
function ShowMe<cfoutput>#CatalogHe ader.RecID #</cfoutpu t>()
{
document.getElementById('M inus<cfout put>#Catal ogHeader.R ecID#</cfo utput>').s tyle.displ ay = "inline";
document.getElementById('P lus<cfoutp ut>#Catalo gHeader.Re cID#</cfou tput>').st yle.displa y = "none";
}
function HideMe<cfoutput>#CatalogHe ader.RecID #</cfoutpu t>()
{
document.getElementById('M inus<cfout put>#Catal ogHeader.R ecID#</cfo utput>').s tyle.displ ay = "none";
document.getElementById('P lus<cfoutp ut>#Catalo gHeader.Re cID#</cfou tput>').st yle.displa y = "inline";
}
</SCRIPT>
</cfloop>
-------------------------- ---------- ---------- ---------- --------
<!---This Div displays the tabbed index title and a plus sign only.--->
<DIV ID="Plus<cfoutput>#Catalog Header.Rec ID#</cfout put>" STYLE="display:inline">
<A HREF="#" class="style11" STYLE="text-decoration : none;" onClick="ShowMe<cfoutput># CatalogHea der.RecID# </cfoutput >()">
<img src="Catalog/icon_GreenCir cle_plus.g if" border="0"><CFOUTPUT> #CatalogHeader.Nomenclatur e#</CFOUTP UT></A><BR >
</DIV>
<!---This Div displays the tabbed index title and a minus sign. It also displays all sub headings, page numbers and links.--->
<DIV ID="Minus<cfoutput>#Catalo gHeader.Re cID#</cfou tput>" STYLE="display:none">
<A HREF="#" class="style11" STYLE="text-decoration : none;" onClick="HideMe<cfoutput># CatalogHea der.RecID# </cfoutput >()">
<img src="Catalog/icon_RedCircl e_minus.gi f" border="0"><CFOUTPUT> #CatalogHeader.Nomenclatur e#</CFOUTP UT></A><BR >
</DIV>
Now I've got a different issue. When I click on the link/icon to expand the hidden items the page displays the idden stuff, but thit also jumps back to the top of the page. I then have to scroll down to the part of the page that I just clicked on. Can you help with this? Is this an anchor tag fix?
I FIGURED IT OUT!!!
Here's the code -
--------------------------
<cfloop query="CatalogHeader">
<SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
function ShowMe<cfoutput>#CatalogHe
{
document.getElementById('M
document.getElementById('P
}
function HideMe<cfoutput>#CatalogHe
{
document.getElementById('M
document.getElementById('P
}
</SCRIPT>
</cfloop>
--------------------------
<!---This Div displays the tabbed index title and a plus sign only.--->
<DIV ID="Plus<cfoutput>#Catalog
<A HREF="#" class="style11" STYLE="text-decoration : none;" onClick="ShowMe<cfoutput>#
<img src="Catalog/icon_GreenCir
</DIV>
<!---This Div displays the tabbed index title and a minus sign. It also displays all sub headings, page numbers and links.--->
<DIV ID="Minus<cfoutput>#Catalo
<A HREF="#" class="style11" STYLE="text-decoration : none;" onClick="HideMe<cfoutput>#
<img src="Catalog/icon_RedCircl
</DIV>
Now I've got a different issue. When I click on the link/icon to expand the hidden items the page displays the idden stuff, but thit also jumps back to the top of the page. I then have to scroll down to the part of the page that I just clicked on. Can you help with this? Is this an anchor tag fix?
ASKER
b0lsc0tt,
I figured out the jumping buit as well.
I had href="#" in my anchor tags for some reason and took that out. It works like a champ.
I figured out the jumping buit as well.
I had href="#" in my anchor tags for some reason and took that out. It works like a champ.
onclick="this.style.displa
That would hide the element. Of course you can't show it by clicking on it for obvious reasons. However if there is something similar between all elements (i.e. tag name, class, etc) then you can use a general script to show all and then hide the clicked element.
This is just one example but please provide details of the type of element and what needs to be done. The attributes and properties you use in the element will be important too. Let me know if you have a question.
bol