Set the initial value for Eayui Datebox
$ ("#ctime"). Datebox ("SetValue", function () {
var date = new Date ();
var CTime = date.getfullyear () + '-' + (Date.getmonth () +1) + '-' +date.getdate ();
return ctime;
});
Get Datebox value
var time = $ ("#ctime"). Datebox ("GetValue");
Html
Date: <input id= "CTime" class= "Easyui-datebox" editable= "false" style= "width:150px;" >
In this case, the value set for Datebox is displayed on the interface, but it is a blank when acquired.
If you choose a time manually for Datebox, you can get the value you chose
How to get the initial value to the Datebox set????
I have also encountered the same problem, I think it is caused by this, your Datebox initialization is the HTML tag on the style, and the use of the JS. All with JS will be useful.
$ ("#ctime"). Datebox ({
Value:function () {
var date = new Date ();
var CTime = date.getfullyear () + '-' + (Date.getmonth () +1) + '-' +date.getdate ();
return ctime;
}
});
-------------------------------------------------------------------------------------
The implementation code is as follows:
$ (function () {
$ (' #txtStartTime '). Datebox (' SetValue ', getnowformatdate ());
$ (' #txtStopTime '). Datebox (' SetValue ', getnowformatdate ());
Setdateboxformat ("Txtstarttime", "txtstoptime");
});
function Getnowformatdate () {
return new Date (). Format ("YYYY-MM-DD");//Hh:mm:ss
}
Reference file Dateformat.js
--------------------------------------
Dateformat.js:
//Call Method: Setdateboxformat ("Txtstarttime", "txtstoptime");
Function Setdateboxformat () {
for (var i = 0; i < arguments.length; i++) {
&nb sp; var txtdateboxid = arguments[i];
$ ("#" + Txtdateboxid). Datebox ({
value:function () {
var date = new Date ();
var ctime = Date.getfullyear () + '-' + (Date.getmonth () + 1) + '-' + date.getdate ();
return ctime;
}
});
}
}
$ (function () {
Calling method: New Date (). Format ("Yyyy-mm-dd hh:mm:ss")
Date.prototype.format = function (format) {
var args = {
"m+": This.getmonth () + 1,
"D+": this.getdate (),
"H +": this.gethours (),
"m+": this.getminutes (),
"S+": This.getseconds (),
"q+": Math.floor ((This.getmonth () + 3)/3),//quarter
"S": This.getmilliseconds ()
};
if (/(y+)/.test (format))
Format = Format.replace (regexp.$1, (this.getfullyear () + ""). substr (4-regexp.$1.length));
for (var i in args) {
var n = args[i];
if (New RegExp ("(" + i + ")"). Test (format)
Format = Format.replace (regexp.$1, regexp.$1.length = = 1? N: ("xx" + N). substr (("" + N). length);
}
return format;
};
});
--------------------------------------
-------------------------------------------------------------------------------------
[Front end _easyui] Set default values for Easyui's datebox, not getting the workaround