php - How to delete an item into an array with a button -
i have code array saves need each time press button, these items saved array showed later erase buttons, don't know how delete it, there part of code shows meant:
echo "<table border=1>"; echo "<tr class='tabpreciostitles'>"; echo "<td>nom activitat</td> <td>nom tipus activitat</td> <td>tipus tarifa</td> <td>temps/km</td> <td>preu</td>"; echo "</tr>"; ($x=0;$x<count($savedarray[4]);$x++){ echo "<tr>"; echo " <td>".$savedarray[0][$x]."</td>"; echo " <td>".$savedarray[1][$x]."</td>"; echo " <td>".$savedarray[2][$x]."</td>"; echo " <td>".$savedarray[3][$x]."</td>"; echo " <td>".$savedarray[4][$x]."</td>"; echo " <td><input type='submit' onclick='eliminar(".$savedarray[0][$x].",".$savedarray[1][$x].",".$savedarray[2][$x].",".$savedarray[3][$x].",".$savedarray[4][$x].")' class='carritoelim' value='elim'></td>"; echo "</tr>"; }
a pic forms:
the other pic shows items on array:
anyone knows how delete selected row references item on array delete button? thanks
in client side, following code works.
for ($x=0;$x<count($savedarray[4]);$x++){ echo '<tr id="line' . $x . '">'; echo " <td>".$savedarray[0][$x]."</td>"; echo " <td>".$savedarray[1][$x]."</td>"; echo " <td>".$savedarray[2][$x]."</td>"; echo " <td>".$savedarray[3][$x]."</td>"; echo " <td>".$savedarray[4][$x]."</td>"; echo " <td><input type='submit' onclick='eliminar('line" . $x . "')' class='carritoelim' value='elim'></td>"; echo "</tr>"; } function eliminar($id) { var elem = document.getelementbyid($id); elem.parentnode.removechild(elem); }
however, if want delete column in server side also, ajax codes should added.
Comments
Post a Comment