| | |
Expand function
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 81
Reputation:
Solved Threads: 0
Hello,
I have copied this code but I do not really understand what this code is about. .
When I put this into my code to expand certain terms, it shows result but it just shows the last record in my table..not taking the variable I posted. Can anyone explain this to me? thank you.
I have copied this code but I do not really understand what this code is about. .
When I put this into my code to expand certain terms, it shows result but it just shows the last record in my table..not taking the variable I posted. Can anyone explain this to me? thank you. javascript Syntax (Toggle Plain Text)
<script> function expand(sec) { thisSec = eval('e' + sec); if (thisSec != null){ if (thisSec.length){ if (thisSec[0].style.display != 'none'){ for (var i=0;i<thisSec.length;i++) {thisSec[i].style.display = 'none'} } else{ for (var i=0;i<thisSec.length;i++) {thisSec[i].style.display = 'inline'} } } else{ if (thisSec.style.display != 'none') {thisSec.style.display = 'none'} else{thisSec.style.display = 'inline'} } } } </script>
Hi there,
that is a toggle function, used to show and hide elements' inside a page. Maybe its meant to toggle some
Is there anything that we can do to help you on solving this issue?
that is a toggle function, used to show and hide elements' inside a page. Maybe its meant to toggle some
<div><elements></elements></div> or it can be a ul tag.Is there anything that we can do to help you on solving this issue?
Last edited by essential; Jul 28th, 2009 at 6:23 am.
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
•
•
Join Date: May 2009
Posts: 81
Reputation:
Solved Threads: 0
Thank you..
What I intend to do is to show related terms when a keyword is inserted to a textbox.
here is my code
then I combined with the js code that I have posted before..
I coded like this afterwards..
however, when I click 'Expand term' after inserting certain keyword,
the list shows the last record in my table terms.
Can anyone tell me what wrong with it?
Your help is much appreciated.

What I intend to do is to show related terms when a keyword is inserted to a textbox.
here is my code
php Syntax (Toggle Plain Text)
<?php $q = $_GET['q'] ; $myquery = "select * from terms where term like '%".$q."%' "; //mysql_free_result(result); $result = mysql_query ($myquery); while ($row= mysql_fetch_array($result)) { $term1 = $row["term1"]; $term2 = $row["term2"]; $term3 = $row["term3"]; } ?>
I coded like this afterwards..
html Syntax (Toggle Plain Text)
<table cellpadding="0" cellspacing="0" width="950" border="0"> <tr> <td><a href="#" onclick="expand(0);return false;"> Expand terms</a></td> </tr> <tr id="e0" style="display:none"> <td colspan="99"> <table border="0"> <tr><td>Related terms</td>></tr> <tr><td><img src="space.gif" height="1" width="100%"></td></tr> <tr><td><?php echo $term1; ?></td></tr> <tr><td><img src="space.gif" height="1" width="100%"></td></tr> <tr><td><?php echo $term2; ?></td></tr> <tr><td><img src="space.gif" height="1" width="100%"></td></tr> <tr><td><?php echo $term3; ?></td></tr> <tr><td><img src="space.gif" height="1" width="100%"></td></tr> </table> </td> </tr> </table>
however, when I click 'Expand term' after inserting certain keyword,
the list shows the last record in my table terms.
Can anyone tell me what wrong with it?
Your help is much appreciated.
Hi,
Sorry to keep you waiting. Here's your requested sample code:
hope it did help...
essential
Sorry to keep you waiting. Here's your requested sample code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>http://www.daniweb.com</title> <style type="text/css"> <!-- .hide { display : none } .show { display : table-row-group; } .block { display : block } --> </style> <script type="text/javascript"> <!-- var expand = ( function() { return expand = function( sec, disp ) { var ie, ff; var disp = (( disp ) ? disp : "show" ); /* http://www.daniweb.com/ NOTICE: - I am not imposing anyone to use this script, i'm just doing what is right and what is good for your browser. */ var ua = ((( ie = document.all[ sec ] ) && !!!( ff = document.getElementById( sec ))) ? 1 : 0 ); var sec = null || { 0 : ff, 1 : ie }[ ua ]; sec.className = (( sec.className === disp ) ? "hide" : disp ); return sec; } } )( ); // --> </script> </head> <body> <div id="main"> <table cellpadding="5" cellspacing="5" border="3" id="terms" frame="border" rules="all" summary="Expand terms" width="50%"> <thead> <tr><td> <!-- Default display is set to "table-row-group" using single parameter inside the expand("arg1") function --> <a href="javascript:void(0);" onclick="expand('e0');">Expand Terms : ( display as a table-row-group )</a><br><br><br> <!-- This an optional display properties, by proving the 2nd arguments' inside the expand( arg1, "arg2" ) function. Your element will then be displayed as a block-level element --> <a href="javascript:void(0);" onclick="expand('e0', 'block');">Expand Terms : ( display as a block-level )</a></td></tr> </thead> <tfoot class="hide"> <tr><td></td></tr> </tfoot> <tbody id="e0" class="hide"> <tr><td>Related Terms</td> </tr> <tr><td><img src="space.gif" height="1" width="100%" alt="spacer"></td></tr> <tr><td><?php echo $term1; ?>Sample Term1</td></tr> <tr><td><img src="space.gif" height="1" width="100%" alt="spacer"></td></tr> <tr><td><?php echo $term2; ?>Sample Term2</td></tr> <tr><td><img src="space.gif" height="1" width="100%" alt="spacer"></td></tr> <tr><td><?php echo $term3; ?>Sample Term3</td></tr> <tr><td><img src="space.gif" height="1" width="100%" alt="spacer"></td></tr> </tbody> </table> </div> </body> </html>
hope it did help...
essential
![]() |
Similar Threads
- How to think like a computer scientist question (Python)
- Parsing an HTML String (JavaScript / DHTML / AJAX)
- Expand/Callapse All Help! (JavaScript / DHTML / AJAX)
- Firefox Compatibility help with script (JavaScript / DHTML / AJAX)
- Savesetting function of VB6 (Visual Basic 4 / 5 / 6)
- Function for assigning variables (Python)
- error: too many arguments to function `mysql_query' (C)
- sas help: INTNX, EXPAND (Computer Science)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Creating table dynamically
- Next Thread: Disable/Lock Text Input Form Fields
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser captchaformproblem cart child close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover onreadystatechange paypal pdf php player position post problem programming prototype redirect safari scale scriptlets scroll search security select software sql toggle unicode variables w3c web website window windowofwords \n





