vendredi 20 août 2021

How to use HTML checkboxes to modifiy a database in Code Igniter?

I am using trying to use code igniter to create an interface where users can check tickboxes next to images, changing a value in our database.

The challenge is that when users check the tickboxes, values are not changed in the database.

If I manually change values in the database, the tickbox values are changed on the interface. But if the user checks the tickbox, the database doesn't change. How puzzling!

The code and interface screenshot are below. The functions veto() and unveto() appear not to be called. I've put an alert in, and they have not been triggered.

Any help or suggestions would be quite helpful, as I'm not sure how to fruitfully approach this problem.

interface

   <section class="page-entry">
      <div class="container padding-32">
         <div class="row">
            <div class="col-12 col-lg-6">
               <h2 class="page-title">Order Preview</h2>
               <div class="hr show-tablet"></div>
            </div><!-- closing title column div -->
         </div><!-- close row -->
      </div><!-- close container -->
   </section>
   <section class="content">
      <div class="container">
         <div class="spacer-h-30"></div>
            <div class="row">
               <?php foreach($previews as $thisPreview){ print_r($thisPreview->preview_id); ?>
               <form class="form-custom">
                 <div class="col-12 col-md-4">
                  <div class="item">
                     <div class="item__header">
                        <?php if($thisPreview->veto) { ?>
                        <input type="checkbox" id="veto" value="1" onclick="veto()" checked>
                        <?php }else{ ?>
                        <input type="checkbox" id="unveto" value="0" onclick="unveto()" >
                        <?php } ?>
                        <!--span class="myicon myicon-save"></span-->
                     </div><!-- item__header -->
                     <div class="item__image">
                        <img src=<?php echo $thisPreview->image_link ?> alt="">
                     </div><!-- item__image -->
                     <div class="item__info">
                        <h3 class="item__title"><?php echo $thisPreview->title ?> </h3>
                        <p class="item__person"><?php echo $thisPreview->customer_name ?></p>
                     </div><!-- item_info -->
                  </div><!-- item -->
               </div><!-- col-12 -->
               </form>
               <?php } ?>
            </div><!-- row -->
      </div><!-- container -->
   </section>
</main>
</body>



Aucun commentaire:

Enregistrer un commentaire