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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:43:03+00:00 2026-06-09T19:43:03+00:00

I have a form and I need two fields to be the same. I

  • 0

I have a form and I need two fields to be the same. I am trying to use javascript to make the second one the same as the first, after the first is set.

Here is the javascript (above my tag)

 <script type="text/javascript" charset="utf-8">    
      function updateDate(){        
      startDate = document.getElementById("startdate").value;      
      document.getElementById("enddate").value = startDate;
 } </script>

and the HTML is as follows:

 <span class="em-events-search-dates em-date-range">
 <input type="text" id="startdate" class="em-date-input-loc em-date-start" onchange="updateDate();" />
 <input type="hidden" class="em-date-input" name="scope[0]" value="<?php if( !empty($_REQUEST['scope'][0]) ) echo $_REQUEST['scope'][0]; ?>" />
 <input type="text" id="enddate" class="em-date-input-loc em-date-end" />
 <input type="hidden" class="em-date-input" name="scope[1]" value="<?php if( !empty($_REQUEST['scope'][1]) ) echo $_REQUEST['scope'][1]; ?>" />
 </span>

The issue I’m having is that when you click the form field, it opens a date selector. I’m pretty sure it uses this exact plugin http://jqueryui.com/demos/datepicker/

Unfortunately, this means that you never actually click the form field after the date is selected, and you never type anything.

I tried onmouseout on the second field (the hidden one with class em-date-input)
I tried onchange on the first element with id startdate

There are a few that work, only if you go back and click the visible field with the date selected. The problem is, a user will never do this.

I even tried putting onsubmit=”updateDate();” on the submit button, hoping that when you clicked it it would change the second date before submitting the form.. No luck. Any suggestions?

EDIT: Added alerts to see what was working and what wasn’t

 <input type="text" onchange="alert('first');" id="startdate" class="em-date-input-loc em-date-start" />
 <input type="hidden" onchange="alert('second');" class="em-date-input" name="scope[0]" value="<?php if( !empty($_REQUEST['scope'][0]) ) echo $_REQUEST['scope'][0]; ?>" />
 <input type="text" onchange="alert('third');" id="enddate" class="em-date-input-loc em-date-end" />
 <input type="hidden" onchange="alert('fourth');" class="em-date-input" name="scope[1]" value="<?php if( !empty($_REQUEST['scope'][1]) ) echo $_REQUEST['scope'][1]; ?>" />

When I change the date on the second box (id=”enddate”) it fires the third alert. No other alerts fire, even when I change the date in the first box multiple times, or by typing.

  • 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-09T19:43:04+00:00Added an answer on June 9, 2026 at 7:43 pm

    If I understood your question then you may want this (confused a little about your question)

    $(function(){
        $('#startdate, #enddate').datepicker();
        $('#startdate').on('change', function(e){
            $('#enddate').val($('#startdate').val());
        });
    });​
    

    Demo or This One.

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

Sidebar

Related Questions

I have two fields on an MVC3 form that must represent the same value.
I need to create a repeat using two fields on the same form. In
I have a form that has a group of 3 text_fields. I need two
I have an html form and I need to populate one of the input
I have a form for managing users, a ModelForm type. But for two fields
I have a simple PHP script with a form that has two select fields,
I have a form with id myform and two fields (dates) with date class.
I have the following two fields in a form: <input type=button value=Rep id=rep name=rep
I have form with one input for email and two submit buttons to subscribe
I have a form and I need to add some data from database before

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.