根据gridview数据和footerrow中的下拉列表值显示和隐藏文本框 [英] show and hide text box based on dropdownlist value inside gridview data and footerrow

查看:51
本文介绍了根据gridview数据和footerrow中的下拉列表值显示和隐藏文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我试图根据下拉列表选择值显示或隐藏文本框。



当选择的值为其他时,文本框将可见。



这是我的javascript代码:



Hi All,

I am trying to show or hide textbox based on drop down list selected value.

When selected value will be "Other" then textbox will be visible.

Here is my javascript code:

$("#gridhvac input[name$='ddlhvacmake_rev']").change(function () {
           if (this.value == "Other") {
               $("#gridhvac input[name$='txtother_rev']").attr("style","display: block;");
           }
           else {
               $("#gridhvac input[name$='txtother_rev']").attr("style", "display: none;");
           }
       });





这里是aspx代码:





and here is aspx code:

<asp:TemplateField HeaderText="MAKE">
        <EditItemTemplate>
        <asp:DropDownList ID="ddlhvacmake" runat="server">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
        <asp:ListItem>3</asp:ListItem>
        <asp:ListItem>4</asp:ListItem>
        <asp:ListItem>Other</asp:ListItem>
        </asp:DropDownList>
<br />
        <asp:TextBox runat="server" ID="txtother" Style="display: none;"/>
        
        </EditItemTemplate>
        <ItemTemplate>
        <asp:Label ID="lblhvacmake" runat="server" Text='<%#Eval("MAKE") %>'/>
        </ItemTemplate>
     <FooterTemplate>
                <asp:DropDownList ID="ddlhvacmake_rev" runat="server">
                <asp:ListItem>1</asp:ListItem>
                <asp:ListItem>2</asp:ListItem>
                <asp:ListItem>3</asp:ListItem>
                <asp:ListItem>4</asp:ListItem>
                <asp:ListItem>Other</asp:ListItem>
                </asp:DropDownList>
                <br />
                <asp:TextBox runat="server" ID="txtother_rev" Style="display: none;"/>
            </FooterTemplate>
        
        </asp:TemplateField>





我无法弄清楚此代码中的错误。这不起作用,也没有错误。



I cannot figure out what's wrong in this code. This does not work and there is no error also.

推荐答案

(#gridhvac input [name
("#gridhvac input[name


='ddlhvacmake_rev' ])。change(function(){
if(this.value ==Other){
='ddlhvacmake_rev']").change(function () { if (this.value == "Other") {


(#gridhvac input [name
("#gridhvac input[name


这篇关于根据gridview数据和footerrow中的下拉列表值显示和隐藏文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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