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 6823257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:45:41+00:00 2026-05-26T21:45:41+00:00

I have a PHP form that presents the user with two radio button options

  • 0

I have a PHP form that presents the user with two radio button options (“All Dates” vs “Date Range”).

I’d like the “Date Range” radio button to be automatically selected if the user begins typing in either a “Start Date” or “End Date”.

As well, I’d like the “Start Date” and “End Date” text fields to clear if the “All Dates” radio button is selected.

Note: The div below is part of a form that can be cloned, hence the “#index#” variables for the id/name elements (so not sure id/name references can be used).

<div>
    <label>Dates to Give:</label>
    <div>
        <input type="radio" name="dates_#index#" id="dates_all_#index#" class="required" value="1" />
        All dates<br />
        <input type="radio" name="dates_#index#" id="dates_range_#index#" class="required" value="0" />
        Date Range:
        <div id="give_from">
            <div>
                <label> Start Date:</label>
                <input type="text" name="start_date_#index#" id="start_date_#index#" class="date start_date" />
            </div>
            <div>
                <label> End Date:</label>
                <input type="text" name="end_date_#index#" id="end_date_#index#" class="date end_date" />
            </div>
        </div>
    </div>
</div>
  • 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-26T21:45:42+00:00Added an answer on May 26, 2026 at 9:45 pm

    Change your HTML (CFML) to this (note the addition of the index=”#index#”):

    <div>
        <label>Dates to Give:</label>
        <div>
            <input type="radio" name="dates_#index#" index="#index#" id="dates_all_#index#" class="required" value="1" />
            All dates<br />
            <input type="radio" name="dates_#index#" id="dates_range_#index#" class="required" value="0" />
            Date Range:
            <div id="give_from">
                <div>
                    <label> Start Date:</label>
                    <input type="text" name="start_date_#index#" index="#index#" id="start_date_#index#" class="date start_date" />
                </div>
                <div>
                    <label> End Date:</label>
                    <input type="text" name="end_date_#index#" index="#index#" id="end_date_#index#" class="date end_date" />
                </div>
            </div>
        </div>
    </div>
    

    And add this JS:

    $(function () {
    
    
        $(".end_date, .start_date").keypress(function () {
            $("#dates_range_" + $(this).attr('index')).attr("checked", true);
        });
    
        $("##dates_all_#index#").click(function () {
            $("##end_date_" + $(this).attr('index') + ", ##end_date_" + $(this).attr('index')).val("");
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contact form that is being submitted, I have PHP validation all
I have a php form that has a known number of columns (ex. top
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
(Using MySQL and PHP) I have a search form that will allow my users
The basics: I have a contact form that uses php to validate the forms.
I have a form (signup.php) that pops up in a nyroModal window when I
I have a php file that contains a form (which contains 2 input boxes
I have a PHP page that queries a DB to populate a form for
I have a form page in PHP that reads a DBF, and conditionally converts

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.