I am pretty new to javascript and PHP so please help me out here.
I have a dropdown checkbox which gets its categories directly from the database. I want to display the checked options in the same format on the same page in a div (<div…/div>). I am not sure how to do this can anyone help me with that. Here is the code for the javascript
[CODE]
function showHideDiv(chkbx, e, count)
{
chkbx =window.document.getElementById(chkbx).checked ;
var categorycount= “totalcategory”+count;
categorycount =window.document.getElementById(categorycount).value;
var element = document.getElementById?document.getElementById(e):document.all?document.all[e]:document.layers?document.layers[e]:null;
if (element == null) return;
if (!chkbx)
{
if (element.style)
{
element.style.visibility = “hidden”;
element.style.display = “none”;
for(i=1; i <= categorycount; i++)
{
var catename = “category”+count+i;
window.document.getElementById(catename).checked = false;
}
}
}
else
{
if (element.style)
{
element.style.visibility = “visible”;
element.style.display = “block”;
}
}
}
The php function is calling this function. Here is the code for the php function.
[code=php]
<?
function DisplayCAtegory($Count,$OddInerestArray,$OddCategryArray)
{?>
<table width=”100%” cellpadding=”0″ cellspacing=”0″ border=”0″>
<?
if(!empty($OddInerestArray))
{// check empty array or not
$Counter=count($OddInerestArray);
for($i=$Count;$i<=$Counter;$i=$i+2)
{// for i
?>
<tr>
<td height=”28″ valign=”bottom”>
<input name=”interest[]” class=”smallfontsize” id=”interest<? echo $i ?>” type=”checkbox”
value = “<? echo $OddInerestArray[$i][‘ID’];?>”
onclick=”showHideDiv(‘interest<? echo $i;?>’, ‘Other<? echo $i;?>’,'<? echo $i;?>’)”
<? if(isset($_POST[‘interest’]) && in_array($OddInerestArray[$i][‘ID’],$_REQUEST[‘interest’])) {?> checked=”checked”<? }?>
/><span class=”smallfontsize”>
<? echo $OddInerestArray[$i][‘Name’].” (“.$OddInerestArray[$i][‘DESC’].”)”; ?></span>
</td>
</tr>
<tr>
<td valign=”top”>
<div id=”Other<? echo $i?>” style=” display:none;”>
<?
$Categorycount = count($OddCategryArray[$i]);
for($j=1;$j<=$Categorycount;$j++)
{?>
<table width=”90%” cellpadding=”0″ cellspacing=”0″ border=”0″>
<tr>
<td valign=”top” style=”padding-left:25px;”>
<input type=”checkbox” class=”smallfontsize” name=”category[]” id=”category<? echo $i.$j; ?>”
value=”<? echo $OddCategryArray[$i][$j][‘ID’] ?>”
<? if(isset($_POST[‘category’]) && in_array($OddCategryArray[$i][$j][‘ID’], $_REQUEST[‘category’])){ ?>
checked
<? }?>
/>
<span class=”smallfontsize”>
<? echo “ ”.$OddCategryArray[$i][$j][‘Name’].”<br>” ;?></span>
</td>
</tr>
</table>
<? }// end of for j;*/ ?>
</div>
<input type=”hidden” id=”totalcategory<? echo $i;?>” value=”<? echo ($j-1); ?>” />
<? if(isset($_POST[‘interest’]) && in_array($OddInerestArray[$i][‘ID’],$_REQUEST[‘interest’])) {?>
<script language=”javascript” >
showHideDiv(‘interest<? echo $i;?>’, ‘Other<? echo $i;?>’,'<? echo $i;?>’)
</script>
<? }?>
</td>
</tr>
<?
$Oddcount =$Oddcount+1;
} //end of for i ?>
<?
}// end of empty array
?>
</table>
<?
}
?>
To see the actual link of how it is coming up visit [URL=”http://www.showecl.com/advertising”]here
To have a a better idea of what i am looking for please click [URL=”http://www.showecl.com/test/pic.png”]here