I have a multi-page table with a loop. The table contains checkboxes. When you select one or more checkboxes are displayed from the values as a list. Within one page everything works correctly, but when I switch to the second page and select the checkbox, immediately the values in the list are reset and the values are displayed only from the second page.
Loop in the table
<?php
while($row1 = mysqli_fetch_array($result1))
{
$rand1 = rand() . "\n";
$rand2 = rand() . "\n";
$rand3 = rand() . "\n";
$rand4 = rand() . "\n";
$rand5 = rand() . "\n";
$rand6 = rand() . "\n";
echo '<tr><td><font face="Verdana">'.$row1["name"].'</font></td>';
echo '<td>
<center>
<font face="Verdana">
<b>
<input type="checkbox"
onclick="usluga()"
id="'.$rand1.'"
class="checkbox-offers"
name="• <font size=2px>'.$row1["name"].'</font><br/>" value="'.$row1["len"].'" />
<label for="'.$rand1.'">'.preg_replace("/^$/","<font color=red size=2px style='text-transform: uppercase;'>Услуга не оказывается</font>",$row1["len"]).'</label>
</b>
</font>
</center>
</td>';
echo '<td><center><font face="Verdana"><b><input type="checkbox" onclick="usluga()" id="'.$rand2.'" class="checkbox-offers" name="• <font size=2px>'.$row1["name"].'<br/>" value="'.$row1["myt"].'" /><label for="'.$rand2.'">'.preg_replace("/^$/","<font color=red size=2px style='text-transform: uppercase;'>Услуга не оказывается</font>",$row1["myt"]).'</label></b></font></center></td>';
echo '<td><center><font face="Verdana"><b><input type="checkbox" onclick="usluga()" id="'.$rand3.'" class="checkbox-offers" name="• <font size=2px>'.$row1["name"].'<br/>" value="'.$row1["tr"].'" /><label for="'.$rand3.'">'.preg_replace("/^$/","<font color=red size=2px style='text-transform: uppercase;'>Услуга не оказывается</font>",$row1["tr"]).'</label></b></font></center></td>';
echo '<td><center><font face="Verdana"><b><input type="checkbox" onclick="usluga()" id="'.$rand4.'" class="checkbox-offers" name="• <font size=2px>'.$row1["name"].'<br/>" value="'.$row1["kr"].'" /><label for="'.$rand4.'">'.preg_replace("/^$/","<font color=red size=2px style='text-transform: uppercase;'>Услуга не оказывается</font>",$row1["kr"]).'</label></b></font></center></td>';
echo '<td><center><font face="Verdana"><b><input type="checkbox" onclick="usluga()" id="'.$rand5.'" class="checkbox-offers" name="• <font size=2px>'.$row1["name"].'<br/>" value="'.$row1["var"].'" /><label for="'.$rand5.'">'.preg_replace("/^$/","<font color=red size=2px style='text-transform: uppercase;'>Услуга не оказывается</font>",$row1["var"]).'</label></b></font></center></td>';
echo '<td><center><font face="Verdana"><b><input type="checkbox" onclick="usluga()" id="'.$rand6.'" class="checkbox-offers" name="• <font size=2px>'.$row1["name"].'<br/>" value="'.$row1["kor"].'" /><label for="'.$rand6.'">'.preg_replace("/^$/","<font color=red size=2px style='text-transform: uppercase;'>Услуга не оказывается</font>",$row1["kor"]).'</label></b></font></center></td>';
}
?>
Function for outputting checkbox values
function usluga() {
var x = [].map.call(document.querySelectorAll('[class="checkbox-offers"]:checked'), function(v) {
return v.name
}).join(' ');
document.getElementById("usluga").innerHTML = x;
};
And here the values are displayed
<p id="usluga"></p>
Help, please. For the second day I am trying to solve the problem.
Big thnx for all!
"` – RiggsFolly Apr 01 '23 at 11:50