House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

JS Question

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Shawn Grover
06/09/2004 11:50 AM

This looks like a case of mixing server side and client side logic.  Try dumping the values of the variables via a JS alert() just before calling the getElementById.  See if it's what you are expecting. Shawn I have a CFLOOP that outputs 10 tables. Think of the 10 tables as pairs of 5. T1 / T2 T3 / T4 T5 / T6 T7 / T8 T9 / T10 There is a link in each top table (T1,T3,T5,T7,T9) that when clicked on should display the table below it (T2,T4,T6,T8,T10 respectively.) The HTML for the link is as follows: <cfloop from="1" to="5" index="x"> <table>   <tr><td><a href="##" onclick="toggleDrillDown('tbl#x#'); return false;">Company #x#</a></td></tr> </table> <table style="display:none;" id="tbl#x#"> .... trimmed off .... </table> </cfloop> The JS is as follows: toggleDrillDown(x){ if(document.getElementById(x).style.display == 'block'){     document.getElementById(x).style.display = 'inline';   } else{     document.getElementById(x).style.display = 'block';   } } The error says "Object Expected" but when I try and pass in document.getElementById("tbl#x#") that does not work either. Any ideas? Thanks! Mike   _____  

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tangorre, Michael
06/09/2004 11:54 AM

> This looks like a case of mixing server side and client side > logic.  Try dumping the values of the variables via a JS > alert() just before calling the getElementById.  See if it's > what you are expecting. Just a bad variable naming choice.... Not mixing it up. :-)

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
06/09/2004 11:57 AM

----- Excess quoted text cut - see Original Post for more ----- This might be way too obvious to be your problem, but I don't see any CFOUTPUT in that HTML. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ phone: 202-797-5496 fax: 202-797-5444

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tangorre, Michael
06/09/2004 12:05 PM

> This might be way too obvious to be your problem, but I don't > see any CFOUTPUT in that HTML. I only included the important code... Left the "gimmes" off :-) Mike

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
06/09/2004 12:21 PM

----- Excess quoted text cut - see Original Post for more ----- You're passing in a string when you call the function, instead of the object itself. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ phone: 202-797-5496 fax: 202-797-5444

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tangorre, Michael
06/09/2004 01:31 PM

> > toggleDrillDown(x){ > You're passing in a string when you call the function, > instead of the object itself. I'm with ya Dave.. However, when I pass in the object I get another error saying ';' expected (even though all the ; are there.... Passing in the object.... toggleDrillDown(document.getElementById('tbl#x#')); Perhaps my syntax for passing objects is off. Am I forgetting something? Mike

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
06/09/2004 03:02 PM

You are missing "function" at the beginning of your function declaration. Also, I suppose you want to hide the related table if you click a second time. What you have there will show the table, but never hide it. function toggleDrillDown(x){   if(document.getElementById(x).style.display == 'block'){     document.getElementById(x).style.display = 'none';     }   else{     document.getElementById(x).style.display = 'block';   } } ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
sudhakar ramaswamy
06/09/2004 04:38 PM

Your code modified a little. Works on IE 6.0. <cfoutput> <cfloop from="1" to="5" index="x"> <table>   <tr><td><a href="##" onclick="toggleDrillDown('tbl#x#'); return false;">Company #x#</a></td></tr> </table> <table style="display:none;" id="tbl#x#"> .... trimmed off .. #x# .... </table> </cfloop> <SCRIPT language="JavaScript">   //initialize to some unused value   var currentElement = '0';   function toggleDrillDown(x){     //return if clicking the same element         if(x == currentElement){       return     }     //if different element and current element !=0 hide current element         else if (currentElement != '0'){       document.getElementById(currentElement).style.display = 'none';       }          //set the currentElem to this     currentElement = x;          //now unhide the new element.                 document.getElementById(x).style.display = 'block';   }   </SCRIPT>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Michael T. Tangorre
06/09/2004 06:03 PM

You are missing "function" at the beginning of your function declaration. No, I just included the necessary code to give you an idea of what I was doing... or trying to do rather. I got it now thought... eval() was needed. Mike

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
06/10/2004 04:01 AM

Just for info: I ran the code you gave in the orriginal post before sending my previous response and just added the <cfoutput> and "function". It never gave me an error. It just didn't collapse a table once it was opened. Pascal ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference