Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3459582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:07:25+00:00 2026-05-18T10:07:25+00:00

I have a simple form with four select fields. If YES is selected on

  • 0

I have a simple form with four select fields. If YES is selected on any form field, the submit button needs to be disabled and a hidden div should appear. Here’s an example of my markup:

<form>
I have read the information on the product(s)<select name="field4"> <option value="Yes">Yes</option> <option value="No">No</option> </select>

Do you have any allergies to any ingredients in product(s)?
 <select name="field5"><option value="Yes">Yes</option> <option value="No">No</option> </select>

Are you pregnant?
 <select name="field6"> <option value="Yes">Yes</option> <option value="No">No</option> </select>

Have you ever used this type of product and had undesirable results?
 <select name="field7"> <option value="Yes">Yes</option> <option value="No">No</option> </select>

<input name="cmdSubmit" type="submit" value="Submit" />
</form>


<div style="display:none;">Hidden div only to appear if any of the four dropdowns are marked YES.</div>

Thanks for your help on this one. I am a jquery novice trying my best to learn.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:07:25+00:00Added an answer on May 18, 2026 at 10:07 am

    I don’t completely understand the business logic of the way you have the form built and your requirements but… going based on what you have said here is what I would do.

    1. write function to check all options, change disable/enable submit, show/hide div
    2. call function on load
    3. call function to check all options every time an option value changes

    .

    checkOptions();
    $("select").change(checkOptions);
    
    function checkOptions() {
      var yesFound = false;
      $("select").each(function(index, element) {
        if ( $(element).val() == "Yes" ) {
          yesFound = true;
        }
      });
    
      if (yesFound) {
        $("#hidden-div").show();
        $("input[type=Submit]").attr("disabled","disabled");
      } else {
        $("#hidden-div").hide();
        $("input[type=Submit]").removeAttr("disabled");
      };
    }
    

    with slightly modified HTML:

    <form>
      <select name="field4"> 
        <option value="Yes">Yes</option>
        <option value="No">No</option>
      </select> I have read the information on the product(s)<br/>
      <select name="field5">
        <option value="Yes">Yes</option>
        <option value="No">No</option>
      </select> Do you have any allergies to any ingredients in product(s)?<br/>
      <select name="field6">
        <option value="Yes">Yes</option>
        <option value="No">No</option>
      </select> Are you pregnant?<br/>
      <select name="field7">
        <option value="Yes">Yes</option>
        <option value="No">No</option>
      </select> Have you ever used this type of product and had undesirable results?<br/>
      <br/>
      <input name="cmdSubmit" type="submit" value="Submit" />
    </form>
    <div id="hidden-div" style="display:none;">Hidden div only to appear if any of the four dropdowns are marked YES.</div>
    

    Example webpage:

    http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-disable-submit-dynamically.html

    On load:

    alt text

    all options ‘No’ but one:

    alt text

    all options ‘Yes’:

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have have a simple HTML form with say four input widgets (see below)...two
I have a simple form: function mymodule_test_form(&$form_state, $nid) { form['submit'] = array( '#type' =>
This is a common problem in ASP MVC. I have a simple search form
I'm creating a .vdproj setup for a simple Windows form. I have added a
In my application I have two queries which will be quite frequently used. The
This seems like such a simple task, but I'm having a hard time finding
I have three tables named Item, Event, and Seat, constructed like this: Item Id
I want to build a back end of a general web form which contains
I am trying to write a stored procedure in MySQL which will perform a
(Revised for content quality) We had built forms based application for a customer based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.