I am trying to teach myself HTML I am very new but am making headway however I have run into an issue. I want to use a date picker to fill a blank with a string of text.
<form action="/action_page.php">
<label for="DayOW">Day of the week:</label>
<input type="date" id="DayOW" name="DayOW">
<div Id="DayOW">_______________</div>
</form>
Above is what I have, how can I fill the ___________ with MM/DD/YYY as text based on what is selected in the date picker?
2
Answers
To achieve this, you can use JavaScript to update the content of the based on the value selected in the date picker. You’ll need to add an event listener to the date input to detect changes and then update the content of the accordingly.
The date format that you request is the US way of representing the date. If you have a date the US format can be created using the Intl.DateTimeFormat object.
When you are using a form a really handy way to update a text is by using the
<output>
element. It can have a name just like the form and the other form fields, so it is easy to refer to.