/    Sign up×
Community /Pin to ProfileBookmark

Checkbox to display drop down menu again on a different place on the same page

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”;
}
}
}
[/CODE]

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’].”&nbsp;(“.$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 “&nbsp;&nbsp;”.$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>
<?
}
?>
[/code]

To see the actual link of how it is coming up visit [URL=”http://www.showecl.com/advertising”]here[/URL] and click on ad placement the checkbox should appear again under ‘Item(s) Selected’ text.

To have a a better idea of what i am looking for please click [URL=”http://www.showecl.com/test/pic.png”]here[/URL] for a pic.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @avnikl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...