PDA

View Full Version : Drop down/ Overlapping Content script not working in PHP loop



progresst
12-02-2010, 10:21 PM
1) Script Title: Drop down/ Overlapping Content script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/overlapcontent.htm

3) Describe problem:


I want to use this in a PHP page that shows a series of database results. The results display fine but the problem I am running into is that when I insert the script into the loop (either within the if statement or outside of it, the <rev=> aspect of the link only works for the first result. The rest of the results try to goto the <href> segment of the script.

Each of the <rev> elements need to open the window with the ASSIGNMENT for that record.

How do I alter this to do this?

Here is a sample of the PHP code with the script <a href> call I am referring to:


<?php do { ?>

<?php echo($row_WADATEST['NAME']); ?>

<?php
if ($row_WADATEST['STATUS'] == 1)
{
?>

<a href="search.htm" id="searchlink" rel="subcontent" rev="/calendar/demo1.php?showCat=<?php echo(substr($row_WADATEST['ASSIGNMENT'], 0, strpos($row_WADATEST['ASSIGNMENT'], "*")+4)); ?>">Calendar</a></b><br />
<!--Drop Down content element -->
<DIV id="subcontent" style="position:absolute; visibility: hidden; border: 9px solid orange; background-color: white; width: 300px; padding: 8px;">

//EMPTY DIV!!

</DIV>
<?php
}
else
{
echo "&nbsp;";
}
?>

progresst
12-03-2010, 12:45 AM
I got it!

I had to take the <div> and the <script> instance and place them inside the loop as well. Once I did that I pulled a unique id, in this case ID and performed a php echo to create a unique instance of the div id and anchor id. Hopefully this will help someone else:

<?php do { ?>

<?php echo($row_WADATEST['NAME']); ?>

<?php
if ($row_WADATEST['STATUS'] == 1)
{
?>

<a href="search.htm" id="searchlink" rel="subcontent" rev="/calendar/demo1.php?showCat=<?php echo(substr($row_WADATEST['ASSIGNMENT'], 0, strpos($row_WADATEST['ASSIGNMENT'], "*")+4)); ?>">Calendar</a></b><br />
<!--Drop Down content element -->
<DIV id="subcontent<?php echo(rawurlencode($row_WADATEST['ID'])); ?>" style="position:absolute; visibility: hidden; border: 9px solid orange; background-color: white; width: 300px; padding: 8px;">

//EMPTY DIV!!

</DIV>
<script type="text/javascript">
//Call dropdowncontent.init("anchorID", "positionString", glideduration, "revealBehavior") at the end of the page:
dropdowncontent.init("searchlink<?php echo(rawurlencode($row_WADATEST['ID'])); ?>", "left-top", 550, "click")
</script>
<?php
}
else
{
echo "&nbsp;";
}
?>