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

  • SEARCH
  • Home
  • 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 8762143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:27:27+00:00 2026-06-13T15:27:27+00:00

I have a form with 5 dropdowns that are generated by php at run

  • 0

I have a form with 5 dropdowns that are generated by php at run time that I want to have validated using jQuery validator. Due to the fact that I have given them an array for the name, validator will only validate the first dropdown, but I need to ensure all 5 are being validated before posting my form.

PHP for making the dropdown

function activityDropDown($id){
      echo('<select id='.$id.' name=activity[]>
          <option></option>
          <option>a</option>
          <option>b</option>  
          <option>c</option>
        </select>');
}
<script type="text/javascript">
            $(document).ready(function(){
        $("#friDate").Zebra_DatePicker({
            format: 'm-d-Y',
            disabled_dates: ['* * * 0-4,6'],
            first_day_of_week: 0,
            onSelect: function(){
                var date = new Date($("#friDate").val());
                $("#mon").val(addDays(date, -4));
                $("#tue").val(addDays(date, -3));
                $("#wed").val(addDays(date, -2));
                $("#thu").val(addDays(date, -1));
                $("#fri").val(addDays(date, 0));        
            }
        });
        $("#form").validate();
        $("#monActivity").rules("add", {
            required: true
        });
        $("#tueActivity").rules("add", {
            required: true
        });
    });
</script>
            <tr>
                <td>Activity:</td>
                <td><?php activityDropDown('monActivity') ?></td>
                <td><?php activityDropDown('tueActivity') ?></td>
                <td><?php activityDropDown('wedActivity') ?></td>
                <td><?php activityDropDown('thuActivity') ?></td>
                <td><?php activityDropDown('friActivity') ?></td>
            </tr>

As you can see, I have tried to manually add the rules based off the elements ID, but it is still doing the same thing; only the first dropdown will validate.

Any help would be greatly appreciated!

  • 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-06-13T15:27:28+00:00Added an answer on June 13, 2026 at 3:27 pm

    Try this:

    function activityDropDown($id){
          static $activitynum = 0;
          echo("<select id='$id' name=activity[$activitynum]>
              <option></option>
              <option>a</option>
              <option>b</option>  
              <option>c</option>
            </select>");
          $activitynum++;
    }
    

    This works around the limitation in the validation plugin by specifying the array indexes explicitly, so the names are distinct.

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

Sidebar

Related Questions

I have an php array that is generated by server-side code. I want to
I have a form that has a few select dropdowns, and I want to
I have the following form that has 2 selects: <form id=form class=form_visitar method=post action=ajax/selects.php>
I have a simple form that has a list (dropdown list generated from a
My scenario is that I have some HTML Dropdowns which fire jQuery on change
I have a form with three dropdowns. What's the easiest way to ensure that
I'm using jQuery UI Selectmenu to style a form's dropdowns. I've created an example
In a form I have one Date text field and 2 dropdowns: Start time
I have developed a script that receives json data from a php script using
I have 1 page that displays a form with various dropdowns that are being

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.