Jump to content
MakeWebGames

Hide/Show help


lucky3809

Recommended Posts

Ok I have been trying, but can't seem to get this to work correctly...

First of all I am using the hide/show script from http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm demo 2....

I am using it in php but seems to not work effectively after a "while statement"....

I want it to hide all names,id tables when clicked, however it seems to only want to hide one id (the one at the top of the list) instead of all ids,names in the tables...

such as for instance...

I have....

 

$nm=$db->query("SELECT id,username FROM users_s  WHERE id=$name ORDER BY id ASC")or die(mysql_error());

 echo '<span id="faqtable1-title" class="iconspan"></span>
          <table style="margin: 0 auto 0 auto; border: solid #292929 0px; width: 90%;">
          <tr class="he">
          <td>ID</td>
         <td style="width: 125px;">Name</td></tr>';


  while($users=$db->fetch_row($nm))
  {
  $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec";

echo '<tr style="background-color: '.$bgcolor .'">
        <div id="faqtable1" class="icongroup">
        <td>'.$users['id'].'</td>
        <td>'.$users['username'].'</td><div></tr></table>';
}
echo <<<EOF
<script type="text/javascript">
var faqtable=new switchicon("icongroup", "div") //Limit scanning of switch contents to just "div" elements
faqtable.setHeader('[Hide]', '[show]') //Set header HTML
faqtable.collapsePrevious(false) //Allow more than 1 content to be open simultanously
faqtable.setPersist(true, 7) //Enable persistence to remember last switch content states for 7 days
faqtable.init()
</script>
EOF;

 

It's only hiding the first ID in the first td, and not both name and id and all info in that whole table, like it should, or how i want it too lol.

Hopefully there is someone out there that can help me or direct me to a website that shows how it is done.

Link to comment
Share on other sites

replace

while($users=$db->fetch_row($nm))   {
  $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec";

echo '<tr style="background-color: '.$bgcolor .'">
        <div id="faqtable1" class="icongroup">
        <td>'.$users['id'].'</td>
        <td>'.$users['username'].'</td><div></tr></table>';




with

 

while($users=$db->fetch_row($nm))
  {
  $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec";

echo '<tr style="background-color: '.$bgcolor .'">
        <div id="faqtable1" class="icongroup">
        <td>'.$users['id'].'</td>
        <td>'.$users['username'].'</td><tr>';
}

print '<div></tr></table>';

 

 

edited

Edited by illusions
removed broken coding
Link to comment
Share on other sites

while($users=$db->fetch_row($nm))
  {
  $bgcolor=($bgcolor == "#ececec") ? "#ffffff" : "#ececec";

echo '<tr style="background-color: '.$bgcolor .'">
        <div id="faqtable1" class="icongroup">
        <td>'.$users['id'].'</td>
        <td>'.$users['username'].'</td><tr>';
}

print '<div></tr></table>';

Well that's not going to work, you'll end up with several nested div elements and no closing divs.

Generally speaking an ID should only appear once within a page, this is why you'll only modify the first element with the id and not the rest of the elements with the ID.

As far as I am aware (someone may be able to confirm/correct this) things like getElementById(); (which I believe you'd be using somewhere within your js) will only return the first it finds.

Link to comment
Share on other sites

Thanks everyone who tried to help.

I figured it out had to do the research from facebook pagnation http://youhack.me/2010/05/14/an-alternative-to-pagination-facebook-and-twitter-style/ which uses php...

Had to put this before the query

<?php

then after the while statement add a few vars, then end the php tag, then do something along the lines such as

<div id="faqtable1" class="icongroup">

<td>

<?php echo $blah; ?>

</td>

</div>

for it to work...

Dunno why it needed to be complicated to work with php but it seemed so.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...