开发者

JS Date output into Hidden Text Field

开发者 https://www.devze.com 2023-03-04 04:40 出处:网络
I am using datejs (see www.datejs.com) to work out date and time for tomorrow (24 hours into the future) and output the date into hidden text box to be inserted into db.

I am using datejs (see www.datejs.com) to work out date and time for tomorrow (24 hours into the future) and output the date into hidden text box to be inserted into db.

This is the code:

<script type="text/javascript">
// submitted
var d1 = Date.today().add(1).days();
document.write(d1.toString('d MMMM yyyy')); //Need to change this to MYSQL format
</script>

<input name="referral_to_be_accepted_by" type="text" value="" id="referral_to_be_accepted_by"/>

At the moment the date (need to add time as well) is shown in doc, but nee开发者_开发问答d to put it in the text box?

Thank you.


try document.getElementById("referral_to_be_accepted_by").value = d1.toString('d MMMM yyyy');

Edit:

<input name="referral_to_be_accepted_by" type="text" value="" id="referral_to_be_accepted_by"/>
<script type="text/javascript">
// submitted
var d1 = Date.today().add(1).days();
document.getElementById("referral_to_be_accepted_by").value = d1.toString('d MMMM yyyy'); //Need to change this to MYSQL format
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消