First Photo:
Second picture
/**
* This method is to go to heavy, so-called deduplication is because the echo to select the value is attached and set to selected the selected state, and when we initialize all the Select Add Option element in the Echo value repeats, then we need to remove the duplicate value in Select option
*/
function Removerepeatselecthour (h) {
var $option =$ ("option:selected", h);//Gets selected,
Alert ($option. Val ());
Console.log ($option. val () + '/' +h.options.length);
var size= h.options.length;
var $options =$ ("option", h);//Get Select all options,
if (h.options.length>25) {//Get checked again, disable the comparison below to remove the data after
$options. Each (function (i,n) {
var options = "";
Alert ($ (n) [0].text];
if ($option. Val () ===$ (n) [0].text && size==h.options.length && $ (n) [0].index!=0] {//&& size== H.options.length can not make the selected and below option Options compare if there are duplicates, and $ (n) [0].index!=0 because the first time you get the data is selected selected value, cannot be deleted!
Alert ($option. val () + '/' +$ (n) [0].index];
h.options[$ (n) [0].index].remove ();//delete the element by $ (n) [0].index the subscript element of option
}
/* $ (h). Find ("option"). each (function (j,m) {
Alert (j);
if (Options.indexof ($ (m) [0].outerhtml) = =-1) {
Options + = $ (m) [0].outerhtml;
}
}); */
$ (n). html (options);
});
}
H.options.remove ($option. Val ());
H.remve ();
}
Hour This function method is not well organized, the interface is to refer to this method, but it is very easy to understand, go back to the next time you can refer to the following, the emphasis on remembering the tag element is not obtained by ID to use this selectObj.options.add (Val, val)); Otherwise use append, don't use appendchild
Function Hour () {
var a=$ ("#sltid"). Find ("option:selected"). Val ();
var sltid= $ (". Sltid");
var sltids= $ (". Sltids");
for (var i = 0; I <=24; i++)
{
var opt = document.createelement ("option");
if (i<10) {
Opt.value = "0" +i;
Opt.innertext = "0" +i;
} else{
Opt.value =i;
Opt.innertext = i;
}
Sltid.append (opt);
}
for (var j = 0; J <=60; J + +)
{
var opts = document.createelement ("option");
if (j<10) {
Opts.value = "0" +J;
Opts.innertext = "0" +J;
} else{
Opts.value =j;
Opts.innertext = j;
}
Sltids.append (opts);
}
}
Page initialization load These time wait drop-down box
$ (document). Ready (function () {
Hour ();
Loadyearormonth ();
Join a page binding
$ ("#Pagination"). Pagination (${mp.page.pages}, {
Callback:pageselectcallback,
Prev_text: "<i></i> prev",
Next_text: "Next page <i></i>",
Link_to: "javascript:",
Items_per_page:1,
Num_display_entries:1,
Current_page: ${mp.page.pagenum-1},
Num_edge_entries:1
});
});
function Loadyearormonth ()
{
var echodate = ' ${mp. Ymdate} ';
var year=echodate.substring (0, 4);
var month=echodate.substring (5, 7);
var now = new Date ();
var currentyear = year;
var currentmonth = month;
Bindselect (document.getElementById (' year '), CurrentYear, CurrentYear + 8, currentyear);
Bindselect (document.getElementById (' month '), 1, currentmonth);
};
function Bindselect (selectobj, Startvalue, Endvalue, SelectedValue)
{
var i = 0;
For (var val = startvalue; Val <= endvalue; val++)
{
SelectObj.options.add (New Option (Val, Val));
if (val = = SelectedValue) selectobj.options[i].selected = true;
i++;
};
};
Select initialization adds the option to give the Echo value through the label, because the Echo value and the initialization value in option have a value repeat, deduplication, and so on!