0

Good Morning,

I am after some help, I am still fairly new to php development so apologies if this one has been answered before,

I have been tasked to build an email migration tracker that automates emails, this part I think I have covered, one part I am not sure with and would love some guidance is the form has checkboxes (check list) which when they are ticked I need the current date to be populated in the textbox next to them, in the correct date format, is there any way in php this can be done, any advice would be much appreciated

Cheers
Martin

2
Contributors
8
Replies
25
Views
4 Years
Discussion Span
Last Post by urbanthistleuk
0

To get you started...

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
<form id="js-tracker-form" name="tracker" action="/tracker" method="POST">
    <p><input type="checkbox" name="check1" value="1"> <input type="text" name="check1date" value=""></p>
    <p><input type="checkbox" name="check2" value="1"> <input type="text" name="check2date" value=""></p>
    <p><input type="checkbox" name="check3" value="1"> <input type="text" name="check3date" value=""></p>
    <p><input type="submit" name="submit" value="Submit"></p>
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
    var today = new Date();
    $("#js-tracker-form").on("click","input[type=checkbox]",function(){
        if($(this).prop("checked")) {
            //the actual checking of the element beats this event handler
            $(this).next().val(today.toDateString());
        } else {
            $(this).next().val('');
        }
    });
</script>
</body>
</html>

JavaScript Date

0

Great thanks very much for this works a dream, I will be able to inplement this into my code, is there anyway of displaying the date in 10/10/2013 formate at all?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.