HTML5/JS How to show DatePicker onload (no libraries )

642 Views Asked by At

I try to show the datepicker popup (input type="date") immediately after the HTML content has loaded. But in my example below, I get only the alert-message. Clicking the ok-button afterwards shows the alert-message and the datepicker. Is this a timing problem? How can I solve this?

Could only test this with Chrome on Android so far. Finally I want to use this with the Android-App Tasker. There you can show scenes (Dialogs) with HTML content. I would prefer a solution without libraries like jquery.

<!DOCTYPE html>
<html>
  <body onload="clickPicker()">
    <p>Select date:</p>
    <input type="date" id="picker">
    <button id="ok" onclick="clickPicker()">OK</button>
    <script>
      function clickPicker()
      {
        alert("clickPicker");
        document.getElementById("picker").click();
      }
    </script>
  </body>
</html>

0

There are 0 best solutions below