I've have the following example code (it can be copied as it is, and run to figure out the problem).
index.php
<doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div style="height:30px;width:100%;">
<div style="height:20px;width:15%;float:left;text-align:center;">
<a href="" id="1" class="reprezentant">AAA</a>
</div>
<div style="height:20px;width:5%;float:left;"> </div>
<div style="height:20px;width:15%;float:left;text-align:center;">
<a href="" id="4" class="reprezentant">BBB</a>
</div>
</div>
<br/><br/>
<div style="height:200px;width:20%;float:left;" id="tabel"></div>
<div style="height:200px;width:78%;float:left;" id="content"></div>
<div style="clear:both;"></div>
<br/><br/><br/>
<div style="height:30px;width:100%;">
<div style="height:20px;width:5%;float:left;"> </div>
<div style="height:20px;width:15%;float:left;text-align:center;">
<a href="" id="btn4">SIZ</a>
</div>
<div style="height:20px;width:5%;float:left;"> </div>
<div style="height:20px;width:15%;float:left;text-align:center;">
<a href="" id="btn5">SIL</a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('.reprezentant').click(function(e){
var rep = $(this).attr('id');
e.preventDefault();
$.ajax({
type: "POST",
url: "tabel.php",
data: {rep:rep},
success: function(resp){
$('#tabel').html(resp);
}
});
});
$('#btn4').click(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "siz.php",
success: function(resp){
$('#content').html(resp);
}
});
});
$('#btn5').click(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "sil.php",
success: function(resp){
$('#content').html(resp);
}
});
});
});
</script>
</body>
</html>
tabel.php
<?php $rep = $_POST['rep']; ?>
<table>
<thead>
<tr>
<th>#</th>
<th>Name</th>
</tr>
</thead>
<tbody><?php
for ($i=1;$i<=$rep;$i++){?>
<tr>
<td><?php echo $i;?></td>
<td>
<a href="" class="locatie" id="<?php echo $i;?>"><?php echo 'Name',$i;?></a>
</td>
</tr><?php
}?>
</tbody>
<tfoot></tfoot>
</table>
<script type="text/javascript">
var loc, btn;
$('.locatie').click(function(e){
e.preventDefault();
loc = $(this).attr('id');
});
$('a[id^=btn4]').click(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "siz.php",
data: {idlocatie: loc},
success: function(html){
$('#content').html(html);
}
});
});
$('a[id^=btn5]').click(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "sil.php",
data: {idlocatie: loc},
success: function(html){
$('#content').html(html);
}
});
});
</script>
siz.php
<?php
$idloc = isset($_POST['idlocatie']) ? $_POST['idlocatie'] : '';
echo $idloc,' ';
?>
SIZ
sil.php
<?php
$idloc = isset($_POST['idlocatie']) ? $_POST['idlocatie'] : '';
echo $idloc,' ';
?>
SIL
After clicking AAA, Name1, and SIZ, the index.php looks like this:
Problem 1: if I press multiple times SIZ or SIL, then the number sent by table.php will be gone. My question would be, how to solve this problem, so that the number stays in siz.php/sil.php script, no matter how many times I press SIZ or SIL?
Problem 2: now, to be able to see the number of the Name, I must follow this steps:
Thank you!