引用
jQuery、moment.js、daterangepicker
例子
$('.x_dates').daterangepicker({
"timePicker": false, // 是否显示时间
//"dateLimit": {
// "days": 7 // 可选中的最大区间(天)
//},
"ranges": { // 快捷栏
"今天": [moment(), moment()],
"昨天": [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
"最近 7 天": [moment().subtract(6, 'days'), moment()],
"最近 30 天": [moment().subtract(29, 'days'), moment()],
"本月": [moment().startOf('month'), moment().endOf('month')],
"上个月": [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
startDate: daterangepicker_startDate, // moment(),
endDate: daterangepicker_endDate, // moment(),
autoUpdateInput: true,
"locale": {
"direction": "ltr",
"format": "YYYY-MM-DD", // YYYY-MM-DD HH:mm
"separator": " 至 ",
"applyLabel": "确定",
"cancelLabel": "取消",
"fromLabel": "From",
"toLabel": "To",
"customRangeLabel": "自定义",
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"firstDay": 1
}
}, function (start, end, label) {
//console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
fn_daterangepicker_changed(start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'))
});
官网(含配置工具)
http://www.daterangepicker.com/
GitHub
https://github.com/dangrossman/daterangepicker
配置工具
下载的包中的 demo.html
Demo
https://awio.iljmp.com/5/drpdemo
xoyozo
4 年前
3,426
<input name="aaa" id="theinput" type="checkbox" />
// 选中它
$('input[name="aaa"]').prop("checked", true);
// 取消它
$('input[name="aaa"]').prop("checked", false);
// 顺便提一下将 select 选中首项
$("#ddl_types option:first").prop('selected', true);
// 获取选中的项
$('input[name="aaa"]:checked').each(function(){ });
// 获取项是否选中
$('#theinput').is(':checked')
或
$('#theinput').prop('checked')
或
theinput.checked
// 获取 radio 选中项的值
$('input[name="aaa"]:checked').val()
xoyozo
7 年前
3,887
CatalogEdit.aspx
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="catalog" DataValueField="ID" Rows="10"></asp:ListBox> <asp:LinkButton ID="LinkButton_up" runat="server" OnClick="LinkButton_up_Click">上移</asp:LinkButton> <asp:LinkButton ID="LinkButton_down" runat="server" OnClick="LinkButton_down_Click">下移</asp:LinkButton> <asp:LinkButton ID="LinkButton_del" runat="server" OnClick="LinkButton_del_Click">删除</asp:LinkButton> <asp:Label ID="Label_alert" runat="server" ForeColor="Red" Text="Label"></asp:Label><br /> <asp:TextBox ID="TextBox_newCatalog" runat="server"></asp:TextBox> <asp:LinkButton ID="LinkButton_add" runat="server" OnClick="LinkButton_add_Click">新增</asp:LinkButton> <asp:LinkButton ID="LinkButton_edit" runat="server" OnClick="LinkButton_edit_Click">修改</asp:LinkButton> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringLink %>" DeleteCommand="DELETE FROM [xLinkCategory] WHERE [ID] = ?" InsertCommand="INSERT INTO [xLinkCategory] ([username],[catalog],[order]) VALUES (?,?,0)" ProviderName="<%$ ConnectionStrings:ConnectionStringLink.ProviderName %>" SelectCommand="SELECT [ID], [catalog] FROM [xLinkCategory] WHERE ([username] = ?) ORDER BY [order],[ID] desc" UpdateCommand="UPDATE [xLinkCategory] SET [catalog] = ? WHERE [ID] = ?"> <DeleteParameters> <asp:Parameter Name="ID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="catalog" Type="String" /> <asp:Parameter Name="ID" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:SessionParameter Name="username" SessionField="username" Type="String" /> </SelectParameters> <InsertParameters> <asp:SessionParameter Name="username" SessionField="username" Type="String" /> <asp:Parameter Name="catalog" Type="String" /> </InsertParameters> </asp:SqlDataSource>
CatalogEdit.aspx.cs
/**//// <summary> /// 上移 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_up_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem != null && ListBox1.SelectedIndex > 0) { string tempValue = ListBox1.SelectedValue; string tempText = ListBox1.SelectedItem.Text; int index = ListBox1.SelectedIndex; ListBox1.SelectedItem.Value = ListBox1.Items[index - 1].Value; ListBox1.SelectedItem.Text = ListBox1.Items[index - 1].Text; ListBox1.Items[index - 1].Value = tempValue; ListBox1.Items[index - 1].Text = tempText; ListBox1.SelectedIndex--; operateDB_move(); } } /**//// <summary> /// 下移 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_down_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem != null && ListBox1.SelectedIndex < ListBox1.Items.Count - 1) { string tempValue = ListBox1.SelectedValue; string tempText = ListBox1.SelectedItem.Text; int index = ListBox1.SelectedIndex; ListBox1.SelectedItem.Value = ListBox1.Items[index + 1].Value; ListBox1.SelectedItem.Text = ListBox1.Items[index + 1].Text; ListBox1.Items[index + 1].Value = tempValue; ListBox1.Items[index + 1].Text = tempText; ListBox1.SelectedIndex++; operateDB_move(); } } /**//// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_add_Click(object sender, EventArgs e) { if (TextBox_newCatalog.Text != "") { //检查同名 bool goon = true; foreach (ListItem li in ListBox1.Items) { if (li.Text == TextBox_newCatalog.Text) { goon = false; } } if (goon) { //操作 SqlDataSource1.InsertParameters["catalog"].DefaultValue = TextBox_newCatalog.Text; SqlDataSource1.Insert(); //设置selected if (ListBox1.Items.Count > 0) { ListBox1.SelectedIndex = 0; } } else { Label_alert.Text = "已存在"; } } } /**//// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_edit_Click(object sender, EventArgs e) { if (TextBox_newCatalog.Text != "" && ListBox1.SelectedItem != null) { int index = ListBox1.SelectedIndex; //检查同名 bool goon = true; foreach (ListItem li in ListBox1.Items) { if (li.Text == TextBox_newCatalog.Text) { goon = false; } } if (goon) { //操作 SqlDataSource1.UpdateParameters["catalog"].DefaultValue = TextBox_newCatalog.Text; SqlDataSource1.UpdateParameters["ID"].DefaultValue = ListBox1.SelectedItem.Value; SqlDataSource1.Update(); //设置selected ListBox1.SelectedIndex = index; } else { Label_alert.Text = "已存在"; } } } /**//// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton_del_Click(object sender, EventArgs e) { if (ListBox1.SelectedItem != null) { int index = ListBox1.SelectedIndex; int count = ListBox1.Items.Count; //检查该 Catalog 下是否有 Link bool goon = true; goon = !checkSubLink(ListBox1.SelectedValue); //下有 Link 则返回真,注意前面有个"!",有则不继续 if (goon) { //操作 SqlDataSource1.DeleteParameters["ID"].DefaultValue = ListBox1.SelectedItem.Value; SqlDataSource1.Delete(); //设置selected if (index < count - 1) //删的不是最末项 { ListBox1.SelectedIndex = index; } if (index == count - 1 && index != 0) //删的是最末项,并且不是最首项 { ListBox1.SelectedIndex = index - 1; } if (index == count - 1 && index == 0) //删的是最末项,并且是最首项 { //不设索引 } } else { Label_alert.Text = "该节点下面存在Link(s),请删除后再删除该节点!"; } } }
xoyozo
16 年前
3,495