dimanche 27 novembre 2016

How to Link checkbox to textfield in html/PHP

Is there any way one can link a checkbox to a textbox. For example

<form>
<table>
    <tr>
       <td><input name="databaseIDs[]" type="checkbox" value="49"/></td>
       <td><input type="text" name="first" value="First Input"/></td>
    </tr>
   <tr>
     <td><input name="databaseIDs[]" type="checkbox" value="50"/></td>
     <td><input type="text" name="first" value="Second Input"/></td>
  </tr>

<tr>
   <td><input name="databaseIDs[]" type="checkbox" value="60"/></td>
   <td><input type="text" name="first" value="Third Input"/></td>
</tr>
<tr>
  <td><input name="databaseIDs[]" type="checkbox" value="38"/></td>
  <td><input type="text" name="first" value="Fourth Input"/></td>
</tr>
</table>

</form>

As you can see, the checkbox is an array and each of the checkbox value is database id. What I am trying to do achieve is to update the database value where id is equal to the id of the checkbox which the user has ticked. For example if the user tick the first checkbox(with the value of 49), and the form is submitted, the database will update the value of in the database where the id is 49.




Aucun commentaire:

Enregistrer un commentaire