Passing a PHP variable to JS
Posted: Mon Feb 04, 2008 5:53 am
Hi,
I have a javascript function that creates a popup div when you click on a link.
The "href" passes an id value to the JS function.
My problem is that each link that passes the id value is within a loop.
What I want to do is pass the value of the current record within the loop when the link is clicked so that that current value can be used to reference the correct record.
Here is my code:
As you can see from my code I am trying to get record specific content to appear in the "new popUp" but the way I have done it only passes the last record in the loop.
Any ideas how to pass record specific id/content to function?
I have a javascript function that creates a popup div when you click on a link.
The "href" passes an id value to the JS function.
My problem is that each link that passes the id value is within a loop.
What I want to do is pass the value of the current record within the loop when the link is clicked so that that current value can be used to reference the correct record.
Here is my code:
Code: Select all
foreach($timeArray as $varTimeSlot)
{
$content=$varTimeSlot;
echo'<div style="overflow:auto; width:100%;">
<div class="timeSlotContainer timeRow">
<div id="' . $varTimeSlot . '" class="timeSlotInnerContainer">' . date("g:ia", strtotime($varTimeSlot)) . '</div>
<div style="float:left; padding:4px;">'; ?><a href="javascript:showbox('div')">Show Div_ID1</a> | <a href="javascript:hidebox('div')">Show Div_ID1</a><? echo'</div>
</div>
</div>';
}
<script>
window.onload=function(){
new popUp(200, 100, 400, 300, "div", "<? echo $content; ?>", "white", "black", "bold 10pt sans-serif", "Appointment", "#0099cc", "white", "#0099cc", "gray", "black", false, true, true, true, false);
}
</script>
Any ideas how to pass record specific id/content to function?