zoukankan      html  css  js  c++  java
  • Jquery取当前选中项后面兄弟节点中某个隐藏域或控件中的值 + 调用 webserivce

    这里介绍一个我遇到的问题。就是在gridview中会放一个checkbox来进行选中与否,会在这个checkbox后面放几个hidden来保存几个需要用到的值,

    现在需要做的是 ,判断选个 选中的checkbox后面 的hidden中的值 是否 是符合条件的,即必须取选中的checkbox后面hidden中的值进行判断,如下:

    <asp:GridView ID="gvTraineeBadge" runat="server" AutoGenerateColumns="False"
        CssClass="Grid" Width="80%" DataKeyNames="ID" >
      <Columns>
          <asp:TemplateField HeaderText="选择">
            <HeaderTemplate>
                <input type="checkbox" name="chkAll" id="chkAll" />
            </HeaderTemplate>
             <ItemTemplate>
                  <input type="checkbox" name="chkCard" class="chkCard" value='<%#Eval("ID") %>' />
                  <input  class="hfBasid" type="hidden"  value='<%#Eval("AssBasID") %>' />
                  <input  class="hfAssessorName" type="hidden"  value='<%#Eval("AssessorName") %>' />
                  <input  id ="hfReturnFlag" class="hfReturnFlag" type="hidden"  value='<%#Eval("Status") %>' />
             </ItemTemplate>
             <ItemStyle HorizontalAlign="Center" />
          </asp:TemplateField>

    </Columns>
    </asp:GridView>

    脚本如下:

    function ReturnBackCard()
    {
        if (confirm("确定要归还吗?") == true)
        {
            var tbid = "";
            var status = "";
            var flag = true;

            var checkNum;
            checkNum = $('.chkCard:checked').length;
           
            if (checkNum <= 0)
            {
                alert("请选择要归还的记录!");
                return false;
            }
            else
            {
                $("input[name='chkCard']:checked").each(
                    function()
                    {

                        //status1 = $(".chkCard:checked~.hfReturnFlag").attr("value");
                        status = $(this).parents("td").find("#hfReturnFlag").val();
                        //alert(status);
                        if (status == "False")
                        {
                            alert("请选择没有归还的记录!");
                            flag = false;
                            return false;
                        }
                        else
                        {
                            tbid += $(this).val() + ";";
                        }
                    });

                if (flag)//为真才处理
                {
                    tbid = tbid.substring(0, tbid.length - 1);
                    $.ajax({
                        type: "post",
                        contentType: "application/json",
                        url: "../SaveDataWebService.asmx/ReturnCardById",
                        dataType: 'json',
                        data: "{tbid:'" + tbid + "'}",
                        success: function(result)
                        {
                            alert("归还成功!");
                            window.location.reload();
                            return true;

                        },
                        error: function(msg)
                        {
                            alert("归还失败!");
                            return false;
                        }
                    });
                    return false;

                }
                else
                {
                    return false;
                }
            }
        }

    }

  • 相关阅读:
    Scalaz(3)- 基础篇:函数概括化-Generalizing Functions
    Scalaz(2)- 基础篇:随意多态-typeclass, ad-hoc polymorphism
    Scalaz(1)- 基础篇:隐式转换解析策略-Implicit resolution
    Scalaz(0)
    泛函编程(38)-泛函Stream IO:IO Process in action
    泛函编程(37)-泛函Stream IO:通用的IO处理过程-Free Process
    泛函编程(36)-泛函Stream IO:IO数据源-IO Source & Sink
    泛函编程(35)-泛函Stream IO:IO处理过程-IO Process
    javascript基础
    jsp联合javascript操作html
  • 原文地址:https://www.cnblogs.com/vihone/p/1806487.html
Copyright © 2011-2022 走看看