Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to add publish time function to dedecms Custom form

Shulou Source: shulou.com Published: 2022-06-02 03:36:49 11月12日 Update

This article is about how dedecms custom forms add release time features. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

How do I add the release time function to the dedecms custom form?

Dedecms custom form is very powerful, can do such as registration system, recruitment system, repair system and so on, the only disadvantage is that after the user submitted the form, the background does not show the submission time.

One way to do this online is:

The code is as follows:

But I tried and the result was not satisfactory. Every time I submitted the form, the time was the same. It shows that this method still doesn't work, and you can test it yourself.

So I share a way to implement the release time through JS from the starting point here, and the process is very simple:

1. Add a text field (not a time field) to the custom form, such as the field name "fill in time" and the field function name "shijian"

two。 In the time field of the form, add the JS code as follows:

The code is as follows:

_ window.onload = function () {var nowDate = new Date (); var str = nowDate.getFullYear () + "+ (nowDate.getMonth () + 1) +"-"+ nowDate.getDate () +" + nowDate.getHours () + ":" + nowDate.getMinutes () + ":" + nowDate.getSeconds (); document.getElementByIdx_x ("shijian"). Value=str;} / / phpfensi.com

Note: because this JS will automatically get the current time to fill in the computer, it is best to hide it with css control so that the filling time is not displayed, or change the property of type to hidden.

3. After submission, the filling time will be displayed in the background.

Thank you for reading! About dedecms custom form how to add release time function to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Tags: Time forms fields functions code methods systems content background more no good practical powerful unsatisfactory unsatisfactory examples functions properties Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker OPPO Reno Xiaomi Apple