To start off I want to mention, that i am just starting out with HTML, PHP and JS. I would like to generate a Website that has a menu on the left and some Content on the right side. And after some tests i managed to do so. Atleast statically.
So far i created a menu on the left, which has some text ("Project") and onclick it will expand and Show some reports. All of that works fine. See here (I left the table border active to demonstrate better)
This is the code I'm currently using to generate this site.
<script type="text/javascript">
$(function () {
$('.click-nav > ul').toggleClass('no-js js');
$('.click-nav .js ul').hide();
$('.click-nav .js').click(function(e) {
$('.click-nav .js ul').slideToggle(200);
$('.clicker').toggleClass('active');
e.stopPropagation();
});
$(document).click(function() {
if ($('.click-nav .js ul').is(':visible')) {
$('.click-nav .js ul', this).slideUp();
$('.clicker').removeClass('active');
}
});
});
</script>
<table border=1 width="100%">
<tr>
<td width="200px" valign="top" align="left">
<div class="click-nav">
<ul class="no-js">
<li>
<a href="#" class="clicker">Project1</a>
<ul>
<li><a href="#">Report1</a></li>
<li><a href="#">Report2</a></li>
<li><a href="#">Report3</a></li>
<li><a href="#">Report4</a></li>
<li><a href="#">Report5</a></li>
</ul>
</li>
</ul>
</div>
</td>
<td>
<center>
<br><br>
<H2>Projects</H2>
<br><br><br><br>
<div id="KPI"><?php require(DB_REP."KPI_report.php")?></div>
</center>
</td>
<td width="50px"></td>
</tr>
</table>
Ok now on to my Problem. The Goal of the site is to dynamically load this part:
<div id="KPI"><?php require(DB_REP."KPI_report.php")?></div>
and i want to do it like this: When Report1,2,3,4 or 5 is clicked i would like to Change the require. So that the php to require is the value of the element that is clicked. In a way like this:
<div id="KPI"><?php require(DB_REP."$clicked.php")?></div>
because later the Buttons Report1, Report2.. etc. will also be generated dynamically by parsing what reports are available.
But so far i found no way to store the value of the element clicked in a php variable. Since I'm getting the click Event in the Java script only.
I hope my Problem is clear and I would appreciate any help. Thanks in advance!