White spaces tree structure..

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

White spaces tree structure..

Post by localhost »

i made this tree structure but there are white space on the pages how can i position these rows using css or what ever...

Code: Select all

<?php
 <?
		   $result=mysql_query("select main_id,main_cat_detail from tbl_main_cat") or die(mysql_error());
		   $num=mysql_num_rows($result);
		   	for($p=0,$i=0;$i<$num;$i++)
			   {
			   $id=mysql_result($result,$i,'main_id');
			   $title=mysql_result($result,$i,'main_cat_detail');
			   	print "<tr><td colspan='2'><p class='redp'><a href='#' onclick='MMDiv$id.style.visibility="visible"';);'>$title $i$p</a></p></td></tr>";
				$result1=mysql_query("select s_cat_id,sub_cat_title from tbl_sub_category where main_id=".$id) or die(mysql_error());
				$num1=mysql_num_rows($result1);
				 for($x=0;$x<$num1;$x++,$p++)
						{
						$sub_id=mysql_result($result1,$x,'s_cat_id');
						$sub_title=mysql_result($result1,$x,'sub_cat_title');
						//if(isset($sendid)&&$sendid==$id) ?>
						<tr><td><? if($x==0){ ?>
						<DIV ID="MMDiv<? print $id ?>" style="visibility:hidden">
						<LABEL FOR="MakeModel">
						<table id="MakeModel" width="100%"><? } ?><tr>
						<td align='right' width='20%'>
						<font size=3><strong>+</strong></font>
						</td>
						<td width="80%">
						<p><? print "$sub_title </p>";
						if($x==0&&$x+1!=$num1)
						print "</td></tr>";
						else if($x+1==$num1)
						print "</td></tr></table></LABEL></DIV>";
						else if($x==0&&$x+1==$num1)
						print "</td></tr></table></LABEL></DIV>";
							?>
						
						<? }
						print "</td></tr>"; ?>
			   <? }
		  ?>

?>
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

if this is an html/css problem you might wanna provide the html and css

you tell us there is whitespace---where and how much? why?
you want help positioning it--how do you want it positioned?

you need to provide more info
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

Post by localhost »

Take this row as an example The main link is Analysis and its subcategories are data analysis and financila analysis .....now its actually two rows white spaces that are unwanted ...i mean i want them to appear when i click analysis but they taking too much space...
<tr>
<td colspan='2'><p class='redp'><a href='#' onclick='MMDiv2.style.visibility="visible"';);'>Analysis
12</a></p>
</td>
</tr>
<tr>
<td>
<DIV ID="MMDiv2" style="visibility:hidden">
<LABEL FOR="MakeModel">
<table id="MakeModel" width="100%">
<tr>
<td align='right' width='20%'> <font size=3><strong>+</strong></font> </td>
<td width="80%">
<p>Data Analysis </p>
</td>
</tr>
<tr>
<td>
<tr>
<td align='right' width='20%'> <font size=3><strong>+</strong></font> </td>
<td width="80%">
<p>Financial Analysis </p>
</td>
</tr>
</table>
</LABEL>
</DIV>
</td>
</tr>
<tr>
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

im still not very clear what you you mean

try removing the <p> tags
maybe thats where the space your talking about is coming from
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

Post by localhost »

i removed <p> tags it still didnt worked....let me put it this way after the main category link there are two rows of its subcategories which are in the div tag on clicking the main category link i make them visible but ....the problem is that when they are not visible they are still using the space of two rows....
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Normally I use the css variable display to hide things. display:block; to show and display:none; to hide. This seems to work as required.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

oh ok makes sense now

do as codergoblin suggested

instead of
visibility: hidden;

use
display: none;

and to make it reappear use
display: block;
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

SOLVED

Post by localhost »

Thanks
that worked...
Post Reply