0

I'm trying to code a form which has an input (of type text) that will be automatically filled out with today's date when the user views the form. I already know how to get today's date in PHP, but I don't know how to make it automatically be typed into the form. This is different than a placeholder because placeholders disappear when the text input is clicked on. I want the date to be as if the user typed it into the form, but done automatically. How would I code this using HTML/CSS?

2 Answers 2

2

You would put it in the value.

<input name="fieldname" value="<php $thedate ?>"/>
Sign up to request clarification or add additional context in comments.

Comments

0

Try something like this give your input id

<input id="date" name="fieldname"/>

Then use jquery to update value

$(doument).ready(function(){
    $('#date').val(new Date());
});

Or with php

<input id="date" name="fieldname" value="<?php echo date("Y-m-d H:i:s"); ?>"/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.