Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
When a user selects startDate and endDate, I want start date to be displayed in other text box

I want to select the startDate from this field: @Html.EditorFor(model => model.TimePeriod.StartDate, new { htmlAttributes = new { @class = "form-control datepicker", @id="StartDate",@onchange="addDates()" } }) @Html.ValidationMessageFor(model => model.TimePeriod.StartDate, "", new { @class = "text-danger" })

Here I want to autopopulate that start date here

<td>
                    @Html.EditorFor(model => model.DailyRegister.Date, new { htmlAttributes = new { @class = "form-control", required = "required", @id = "date1" } })
                    @Html.ValidationMessageFor(model => model.DailyRegister.Date, "", new { @class = "text-danger" })
                    <script>
                            function addDates() {
                            document.getElementById("date1").value = document.getElementById("StartDate");
                        }
                    </script>
                </td>

Running above code gives this result

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It might be a silly question, but have you tried getting the value of the start date field instead?

document.getElementById("date1").value = document.getElementById("StartDate").value;

Depending on when you call the addDates() function you might need an event listener as well.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!