WhiteShadow
WhiteShadow

Reputation: 333

Set HTML Date Picker With Javascript Function

I'm trying to take a date from a date picker and then output the date to the value of a second picker.

I should work like this,

  1. fill in dateIn
  2. press button
  3. date displayed on dateOut picker

My code:

<input id="dateIn"  name="dateIn"  type="date"  value=""/>
<input id="dateOut" name="dateOut" type="date"  value=""/>

<button type="button" onclick="FunctionDate()">Click Me!</button>

Here is the function: (It does run when the button is pressed)

function FunctionDate() {   
    Document.getElementById("dateOut").value = Document.getElementById("dateIn").value;
}

The problem is in the function, but what should run in there?

Upvotes: 0

Views: 734

Answers (1)

tymeJV
tymeJV

Reputation: 104795

Forgot the quotes around element ID's:

document.getElementById("dateOut").value = document.getElementById("dateIn").value;

And remove the () from the .value call. Just a tip, always have your console open when writing JS, you'll see the syntax errors.

Upvotes: 4

Related Questions