473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Collapsible Panel that increases it's id every time in my loop

I have Collapsible Panel and this is the header of it,
Expand|Select|Wrap|Line Numbers
  1. <div id="CollapsiblePanel1" class="CollapsiblePanel">
  2.      <div class="CollapsiblePanelTab" tabindex="0">Comments</div>
  3.      <div class="CollapsiblePanelContent">
  4.        Content 
  5.      </div>
  6. <div>
  7.  
now I get the content from my DB and every time I get more content I go in new CollapsiblePanel all I need to know how to increases the id="CollapsiblePanel1" to be id="CollapsiblePanel2" and id="CollapsiblePanel3" and ect.

OK I have updated to all code of the page hope you get my point here
Expand|Select|Wrap|Line Numbers
  1. <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
  2. <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
  3.  
  4. <script type="text/javascript">
  5. var index = 1;  
  6. function update() {
  7.     document.getElementById('CollapsiblePanel'+index).id = 'CollapsiblePanel'+(index+1);
  8.     index++;
  9. }​
  10. </script>
  11.  
  12. <?php
  13.  
  14.     $getBlogers ="select * from blogs where active=1";
  15.     $result = $db -> query ($getBlogers) or die ($db->error);
  16.  
  17. ?>
  18. <style type="text/css">
  19. .UsersBlog #blogerComments tr .blogCommentsText {
  20.     border: 1px solid #CCC;
  21. }
  22. </style>
  23.  
  24.  
  25. <div id='contentBody_tutorials'>
  26. <table width="560" border="0">
  27.   <tr>
  28.     <td width="68"><img src="images/shareIcon.jpg" width="64" height="77" alt="share" /></td>
  29.     <td width="482" class="TextShareYourTutorials">Share your knowledge <span class="whatIsAllAbout">what is this about?</span></td>
  30.   </tr>
  31. </table>
  32. <p>&nbsp;</p>
  33. <div id="contentOnContentBody_blog">
  34.   <table id="blogerHeader" width="575" border="0" cellpadding="5">
  35.     <tr>
  36.       <td width="121" rowspan="4" align="center" valign="middle"><img src="images/userInvisible.jpg" width="80" height="80" /></td>
  37.       <td colspan="2">Welcome</td>
  38.     </tr>
  39.     <tr>
  40.       <td colspan="2">Your have 5   blogs</td>
  41.     </tr>
  42.     <tr>
  43.       <td colspan="2">Last blog date</td>
  44.     </tr>
  45.     <tr>
  46.       <td width="135"><a href="#">Add new blog</a></td>
  47.       <td width="198"><a href="#">View my blogs</a></td>
  48.     </tr>
  49.   </table>
  50.   <hr align="left" noshade="noshade" style="border:dotted 1px #b2b2b2;" />
  51. <?php
  52.     while ($blogsRow = $result -> fetch_object())
  53.     {
  54. ?>
  55. <div class="UsersBlog">
  56. <img style="margin-right:5px;" src="images/userInvisible.jpg" width="49" height="49" align="left" /><span class="blogTitle"><?php echo $blogsRow->Btitle; ?></span><br /><span class="ByNameCommenter"><?php echo $blogsRow->ByName; ?><br /><?php echo $blogsRow->dateAdded ?></span>
  57.    <br />
  58.    <img style="margin:5px 0 5px 0;" src="images/roler_of_blogs.jpg" width="407" height="1" alt="ruler" />
  59.    <br />
  60.    <p><?php echo $blogsRow->Bdescription; ?></p>
  61.    <br />
  62.    <p><a href="includes/postComments.php?id=<?php $gotIT=$blogsRow->id; echo $gotIT; ?>"><span class="commentLink">Comment</span></a> - <span class="reportLink">Report</span></p>
  63.  
  64.    <div id="CollapsiblePanel" class="CollapsiblePanel">
  65.      <div class="CollapsiblePanelTab" tabindex="0">Comments</div>
  66.      <div class="CollapsiblePanelContent">
  67.    <table width="400" border="0" cellpadding="5" cellspacing="0" id="blogerComments">
  68.    <?php
  69.    $getComments="select * from blogscomments where blogestID=$gotIT";
  70.    $getCommentsRuselts = $db -> query ($getComments) or die ($db->error);
  71.    while($rows = $getCommentsRuselts ->fetch_object()) {
  72. ?>
  73. <tr>
  74.      <td align="left" class="grayBoldText">by: </td>
  75.      <td align="left" class="normailDarkBlueText"><?php echo $rows->name; ?></td>
  76.      <td align="left" width="38" class="grayBoldText">Date: </td>
  77.      <td align="left" class="normailDarkBlueText"><?php echo $rows->dateCommented; ?></td>
  78.    </tr>
  79.  
  80.    <tr>
  81.    <td colspan="4" bgcolor="#F3F3F3" class="blogCommentsText"> <?php echo $rows->comments; }?></td>
  82.    </tr>
  83.    </table>
  84. </div></div></div>
  85. <?php
  86.     }
  87. ?>
  88.  
  89. </div>
  90.  
  91. <script type="text/javascript">
  92. var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1");
  93. </script>
  94.  
Mar 23 '12 #1

✓ answered by Marknut

My apologies if I don't completely understand the need here, but I think you might want to add a variable:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $currentID = 0;
  3.     while ($blogsRow = $result -> fetch_object())
  4.     {
  5.         $currentID++;
  6. ?>
  7. [other code...]
  8.  
  9.    <div id="CollapsiblePanel<?php echo $currentID; ?>" class="CollapsiblePanel">

2 2642
Marknut
42
My apologies if I don't completely understand the need here, but I think you might want to add a variable:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $currentID = 0;
  3.     while ($blogsRow = $result -> fetch_object())
  4.     {
  5.         $currentID++;
  6. ?>
  7. [other code...]
  8.  
  9.    <div id="CollapsiblePanel<?php echo $currentID; ?>" class="CollapsiblePanel">
Mar 23 '12 #2
Yes this is right you got me, many thanks brother should say the last part of it that the Spry javascript that usually appears at the foot of the page will move it within the loop itself to be something like this

Expand|Select|Wrap|Line Numbers
  1. <div id="<?php echo "CollapsiblePanel".$curentID; ?>" class="CollapsiblePanel">
  2.      <div class="CollapsiblePanelTab" tabindex="0">Comments</div>
  3.      <div class="CollapsiblePanelContent">
  4.      <script type="text/javascript">
  5. var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("<?php echo "CollapsiblePanel".$curentID; ?>", {contentIsOpen:false});
  6. </script>
Many thanks Marknut for this great help really you made me happy

Regards

Yousef Altaf Wasti
Mar 24 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chad | last post by:
I have COM component embedded on html page. It has version 1.0.0.1 (by default). I have converted it in cab file. Code of html is something like: <HTML><HEAD></HEAD><BODY><OBJECT...
8
by: Scott M | last post by:
I have a procedure in my Dispose method that records my application was closed in a database. However, when I kill a process or an unhandled exception occurs this does not seem to run. Is there...
6
by: Bill | last post by:
Hi all, How would I set up a script to run every time a user comes to a page (even if they come to the page via the back button)? Thanks! Bill
26
by: Ravindra.B | last post by:
I have declared a global variable which is array of pointers and allocated memory for each array variable by using malloc. Some thing similar to below... static char *arr; main() { int i;
4
by: Frank Lund | last post by:
Should we call .Dispose() every chance we get... on every object that exposes .Dispose()... and every time we have such an object? For example, is it true that *every* time I create a DataTable...
1
by: vineet1987 | last post by:
i want to generate a series of random numbers like 00101 01011 01111 01010 11101 it is a 5*5 matrix and is random every time upon execution my code is:-
1
by: CaliRattler549 | last post by:
Every time it comes two the second player it tells me space already used. What am I doing wrong? #include <iostream> #include <string> #include <cmath> using namespace std; //<strong class =...
1
by: jay123 | last post by:
Hi, i am using window.onload in HTML code which is like<script type="text/javascript" language="javascript"> window.onload = function(){ ShowPanel1(); return false; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.