mardi 4 octobre 2016

Post hidden value only if checkbox is selected

So the idea is that a hidden value is only posted when the actual checkbox is selected.

So i have a loop (size depends on the number of rows from db) that generates these checkboxes. Each checkbox already has name, id and value set so i can not add 2nd value to the checkbox - or there is a way?.

<div class="funkyradio-info">
    <?php echo "<input type='checkbox' name='acdQueueID[]' id='".$queue['id']."' value='".$queue['id']."' checked />" ?>
    <?php echo "<label for='".$queue['id']."'>".$queue['name']."</label>" ?>
    <?php echo "<input type='hidden' name='acdQueueName[]' value='".$queue['name']."' />" ?>
</div>

Mind you that the form submits to my Controller via

<form id="form" method="POST" action="<?php echo site_url('Home/getData') ?>"">

Aucun commentaire:

Enregistrer un commentaire