I have a foreach loop that generates an input with type of checkbox with items (from DB).
Right now, there is no default checkbox that is checked and every time a user checks the checkbox it calls to JS function.
Now, the clients wants me to check the first checkbox by default. I know how to check it but how do I call the JS function by default?
This is my HTML - the update_addon() is JS func.
<? foreach ($pros as $pro):?>
<label class="checkbox text-left">
<input type="checkbox" name="checkbox"
onchange="update_addon(<?=$pro['id']?>,this)">
<?=$pro['name']?> ( <?=$pro['price']?> )
</label>
<? endforeach; ?>
The update_addon() is an AJAX call.