|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
JS Question
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 Grover 06/09/04 11:50 A > This looks like a case of mixing server side and client sideTangorre, Michael 06/09/04 11:54 A > There is a link in each top table (T1,T3,T5,T7,T9) that whenDave Watts 06/09/04 11:57 A > This might be way too obvious to be your problem, but I don'tTangorre, Michael 06/09/04 12:05 P > <tr><td><a href="##" onclick="toggleDrillDown('tbl#x#');Dave Watts 06/09/04 12:21 P > > toggleDrillDown(x){Tangorre, Michael 06/09/04 01:31 P You are missing "function" at the beginning of your functionPascal Peters 06/09/04 03:02 P Your code modified a little.sudhakar ramaswamy 06/09/04 04:38 P You are missing "function" at the beginning of your functionMichael T. Tangorre 06/09/04 06:03 P Just for info: I ran the code you gave in the orriginal post beforePascal Peters 06/10/04 04:01 A 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 _____ > 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. :-) ----- 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 > 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 ----- 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 > > 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 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 ----- 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> 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 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 -----
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||