如何获得时间选择复选框 [英] how to get time on checkbox selection

查看:62
本文介绍了如何获得时间选择复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取要保存在表中的复选框选择时间,并且还限制了复选框不超过时间限制

解决方案

您好,

在这里,我写了一些代码来限制选择

 <   html     xmlns   =" > 
<      ="  服务器" <  标题 >  <  /title  > 
    <  脚本    ="   Scripts/jquery-1.4.1-vsdoc.js" span>   类型  =" 文本/javascript" <  / 脚本 > 
    <  脚本    ="   Scripts/jquery-1.4.1.js"   类型  ="  >  <  / > 
    <  脚本   语言  ="   javascript" > 
         var  tim =  500 ;
         var  tmp;
        函数 f1(tagid){
           
            如果( parseInt (tim)==  0 ){
                文档 .getElementById(tagid).checked =  false ;
            }
        }
        函数 strt(){
            如果( parseInt (tim)>  0 ){
                tim =  parseInt (tim)- 1 ;
                tmp = setInterval("  100 );
            }
            其他 {
                tim =  0 ;
            }
        }
    <  / 脚本 > 
<  /head  > 
<  正文 > 
    <  表单    ="   form1"  runat   >服务器"  > 
    <   div  > 
      <  输入      ="        ="     ="   btnstart"  onclick    strt() " / <  输入    ="  复选框" <​​/span>  id    check1"     =" 选项1"  onclick    f1(this.id)" / <  输入    ="  复选框" <​​/span>  id    Checkbox2"     =" 选项2"  onclick    f1(this.id)"   > 
        <  输入    ="  复选框" <​​/span>  id    Checkbox3"     =" 选项3"  onclick    f1(this.id)"   > 
        <  输入    ="  复选框" <​​/span>  id    Checkbox4"     ="  option4"  onclick    f1(this.id)"   > 
       
    <  /div  > 
    <  /form  > 
<  /body  > 
<  /html  >  



试试这个可以帮助您


最好的


感谢以帮助
但是我不希望它限制条目,而只是将复选框检查的时间保存到我的datagrid中.获取复选框的时间.

您也可以在选中控件后将其禁用,以限制用户下次单击该控件.


i want to get checkbox selection time which is to be saved in table and also restricted the checkbox not to excedd the time limit

解决方案

Hi,

Here I write some code to restrict selection

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language ="javascript" >
        var tim = 500;
        var tmp;
        function f1(tagid) {
           
            if (parseInt(tim) == 0) {
                document.getElementById(tagid).checked = false;
            }
        }
        function strt() {
            if (parseInt(tim) > 0) {
                tim = parseInt(tim) - 1;
                tmp = setInterval("strt()", 100);
            }
            else {
                tim = 0;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <input type ="button" value ="start" id="btnstart" onclick="strt()" />
        <input type="checkbox" id="check1" value="option1" onclick="f1(this.id)" />
        <input type="checkbox" id="Checkbox2" value="option2" onclick="f1(this.id)"  />
        <input type="checkbox" id="Checkbox3" value="option3" onclick="f1(this.id)"  />
        <input type="checkbox" id="Checkbox4" value="option4" onclick="f1(this.id)"  />
       
    </div>
    </form>
</body>
</html>



try this it can helps you


All the Best


thanx for the help
but i dont want it restrict the entry but just to save the checkbox checked time into my datagrid


Set the property AutoPostBack = "true", and bind an event handler like checkbox1_CheckedChanged, where you can get the time of the checkbox checked.

You can also disable the control after it is checked, to restrict the user to click the same next time.


这篇关于如何获得时间选择复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆