dimanche 28 juin 2020

how to update hidden checkbox in html input

i have an html input page to add scores in a grid.

   status valueA valueB checkboxA checkboxB
1       4      5      2         x         x
2       3      3      1                   x
3       5      7      2                   
4       4      6      3         x

including some checkboxes like this one with a ng-hide condition (angularjs) if the status is 3. (means all status with the number 3 on it, i dont need to see so i am not able to check the checkbox.)

<form action="/save_score.php">
  ...
  <td><input type="hidden" value="0" name="checkboxA1"/>
  <input type="checkbox" value="1" name="checkboxA1" ng-hide="status1 == 3"/></td>
  ...
  <input type="submit" value="Save">
</form> 

this input page works fine. the checkboxA2 with status2 = 3 for example i cant see therefore cant check. and the others are visible and i can use them properly. the scores are added to the system correctly.

later on after i saved the scores, i can go into a kind of history page of all added scores of different dates where i see all the scores from previous times where i can change them (i need this page because sometimes it happens that i made a mistake and want to alter the scores) i click on Details of a score and come back in to the score grid.

Score History

Date        Score  
11-11-2019  89     Details 
10-10-2019  90     Details 
09-09-2019  88     Details 
...

among them also the checkboxes.

<form action="/update_score.php">
  ...
  <input type=“checkbox” value= “<?php echo $checkboxA1; ?>” name="checkboxA1" <?php if($checkboxA1) { 
  echo 'checked="checked"';} ?>></td> 
  ...
  <input type="submit" value="Update">
</form> 

now i would like to change this line so the checkboxes with status 3 are hidden. but till now i didnt find a way to hide the respective checkboxes without getting an update error.

i tried this in the input type... (that makes the respective checkboxes disappear)

  type="<?php if ($status1 > 3) {echo 'checkbox';} else { echo 'hidden';}?>"

the hidding of the checkboxes is a design feature, i wanted to add, because it looks nicer and it avoid additional errors during the entering and updating of the scores, but it doesnt work yet, because all the hidden checkboxes cant be updated. they all return "" which my mysql database update doesnt accept.

so my question is, how to hide the checkbox and get the update correctly




Aucun commentaire:

Enregistrer un commentaire