Sauter la navigation

[Résolu] enabling submit button when at least 1 is selected

This support ticket is created Il y a 4 années et 4 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Marqué : ,

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par davidm-13 Il y a 4 années et 4 mois.

Assisté par: Minesh.

Auteur
Publications
#1754061

Hi,
I have the following form that's submitted.

    <form action="?page_id=19218" method="post" id="myFormID">
       <label class="label-right" for="wpv-complaint">Complaint Treated:</label>
          [xyz-ips snippet="select-complaint"]
       <label class="label-right" for="wpv-system-state">System / State Effected:</label>
         <select name="wpv-system-state" class="require_one">
           <option value="" disabled selected hidden>No System / State selected</option><br/>
      [xyz-ihs snippet="select-options-system"]
      </select> 
       <label class="label-right" for="wpv-actions">Herbal Action:</label>
         <select name="wpv-actions" class="require_one">
           <option value="" disabled selected hidden>No Herbal Actions selected</option><br/>
         [xyz-ihs snippet="select-options-actions"]
      </select>
      <!-- See JS editor to enable submit button  -->
    <p style="font-size: 14px;">Select plants who's medicinal use includes:<br>
      a) All the selected terms <input  type="radio" name="all-any" value="All" checked><br>
      b) Any of the selected terms <input  type="radio" name="all-any" value="Any">
     </p>  
      <div>
  <!--    <button class="btn button" name="submit">Search</button>   -->
        <input  class="button" id="mySubmit" type="submit" value="search" name="submit">
       <button class="btn butt"> Clear Search</button>
       </div> 
  </form>

And this JavaScript - in the JS editor of content template that contains the above form

jQuery(function($){
$('#mySubmit').attr('disabled','disabled');

$('select').change(function(){
    if ( $(this).hasClass('require_one') ){
        $('#mySubmit').removeAttr('disabled');
    }
});

$('#mySubmit').click(function() {
   $('#myFormID').submit(); 
});
});  

I found this code as an example to only enable the submit once at least one <select> was selected, but it's not working - it has no effect on the front-end - any idea why?
Thanks for any help

#1755567

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and access details as I need to check your current setup and how you configured your Search form as well as how exactly you added your JS.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1756617

My issue is resolved now. Thank you!