jquery+ashx checkbox 单选判断是否true 和 false 传值操作

示例图:

html标签代码:

        <p></p>
        <label for="checkbox" style="float:left" >是否常用:</label>
        <input type="checkbox" name="ChkIsUse" id="ChkIsUse" value=""   style="width:10px" />
<
p></p>
jquery

//录入信息传递参数值时

$(function (){

tag = "add";

 var ischeck = $("#ChkIsUse").attr("checked") == "checked" ? 1 : 0;//是否常用 获取值 1常用

$.post('/ashx/Handler.ashx', { fun: 'save', tag: tag, ischeck: ischeck },

}

       //编辑修改
        function editInfo(guid) {
            tag = "edit";
           
            $("#dialog-form").dialog("open");
            $.post("/ashx/Handler.ashx", { fun: 'get', type: iType }, function (data, status) {
                $("#SelectNode").append(data);
            });
           
            $.post("/ashx/Handler.ashx", { fun: 'model', guid: guid }, function (data, status) {
                result = eval('(' + data + ')');
              
                strGuid = guid;
                $("#SelectNode").attr("value", result.ParentNode);
                $("#ChkIsUse").attr("checked",result.IsPopular==1);//取到值时为1项显示true 为0 则false IsPopular为数据表字段属性
      
            });
        }
Handler 一般处理程序文件Handler.ashx:

//获取传递值 是否常用

   string tag = context.Request.Form["tag"];
   string ischecked = context.Request.Form["ischeck"];

if (tag == "add") //添加
                    {
                        strBuilder.Append((addInfo( ischecked)));
                    }
                    else
                    {     //修改
                        string strguid = context.Request.Form["guid"];
                        if (editInfo( ischecked,strguid))
                              strBuilder.Append("success");
                          else
                              strBuilder.Append("error");
                    }
                    context.Response.Write(strBuilder);

//添加

private string addInfo( string ischecked)
        {
            Model.info model = new Model.info();        
            model.IsPopular = Convert.ToInt32(ispopular);//是否常用   

           //这里就是增加数据信息的操作方法了  省略
            if (bll.Add(model))
                return model.guid.ToString();
            else
                return "";
        }

//编辑修改信息

 private bool editInfo( string ischecked, string guid)
        {
            Model.info model = new Model.info();
            model = bll.GetModel(new Guid(guid));
           
            model.IsPopular = Convert.ToInt32(ispopular);//是否常用
            //这是修改信息操作 省略
            return bll.Update(model);
        }

 

 

 

转载于:https://www.cnblogs.com/Warmsunshine/p/3569256.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值