lundi 14 septembre 2020

How to click the checkbox with url? [closed]

I understand that we can pre-fill some data in an HTML form using the URL. For example, www.example.com/?itemname=sth

While this time I would like to perform a click action through the URL for my filter to work. I have written the following code to click the checkbox but it doesn't work, May I know how to fix it? Thanks.

<label class="form-check-label">
      <input type="checkbox" class="form-check-input product_check" id="Tutor_subject_1" name="Maths" value="Maths">Maths<br>
       <?php if (isset($_GET['itemname']) && $_GET['itemname'] === 'sth' ): ?> 
           <script>document.getElementsByName("Maths").click();</script>
       <?php endif; ?>
</label>




Aucun commentaire:

Enregistrer un commentaire