I have a simple COTG form designed for COVID track and trace.
In this form, we want to show the the email address input if the user checks the “Do you have an email?” case. The input field is hidden by default
I also need to click on the Add button and display the initial state of the row with the checkbox unchecked and the email input field hidden. But the hidden DIv is shown by default and the click event has no effect on the added rows.
I know it’s simple but I am disgning it for the first time given we have just purchased 50 COTG licences as we were given assurances COTG can achieve this. Can anyone helps?
This is the source code of the template which is pretty basic and which you will need to use with the cotg-2.0.0.js api. Basically just use any starter COTG template and copy the below source html code and javascript script
<div class="row">
<div class="columns">
<table id="users_table" class="table-no-style" role="cotg-table" cellpadding="0" cellspacing="0" style="width: 100%;">
<thead>
<tr>
<td style="width: auto%;"></td>
<td style="width: 10%;">
<br>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="small-12 columns">
<label>Name
<input name="customer_name" placeholder=" enter your name" type="text">
</label>
</div>
<legend>
<input id="user_email" value="" name="check_user_email" type="checkbox">
<label for="user_email">Do you have an email?</label>
</legend>
<div id="check_user_email" class="check_user_email" style="display:none;">
<div class="row">
<div class="small-12 columns">
<label>email address
<input "="" name="user_email" placeholder="email address" type="email">
</label>
</div>
</div>
</div>
</td>
<td class="text-right">
<button class="round tiny secondary del-row" role="cotg-delete-row-button" type="button">Del</button>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="text-right" colspan="6">
<button class="round tiny add-row" role="cotg-add-row-button" type="button">Add</button>
</td>
</tr>
</tfoot>
</table>
</div>
AND THE SCRIPT
$( document ).ready(function() {
$('input[type="checkbox"]').click(function() {
var inputName = $(this).attr("name");
$("." + inputName).toggle();
});