DropDownList 无刷新联动

 

关键是找到客户端Textbox的id

js代码如下

<script type="text/jscript" >
    function ss(ddl)
    {
document.getElementById(ddl.id.replace('ddlLevel','txtScore')).value=ddl.options[ddl.selectedIndex].value

    }
  
    </script>

Gridview代码:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                        <Columns>
                            <asp:TemplateField ShowHeader="False">
                             <ItemTemplate>
                                 <asp:DropDownList ID="ddlLevel" onchange="ss(this)" runat="server">
                                 <asp:ListItem Text="A" Value="950"></asp:ListItem>
                                 <asp:ListItem Text="B" Value="825"></asp:ListItem>
                                 <asp:ListItem Text="C" Value="675"></asp:ListItem>
                                 <asp:ListItem Text="D" Value="500"></asp:ListItem>
                                 <asp:ListItem Text="E" Value="200"></asp:ListItem>
                                 </asp:DropDownList>
                                      </ItemTemplate>
                         </asp:TemplateField>
                               <asp:TemplateField ShowHeader="False">
                             <ItemTemplate>
                                 <asp:TextBox ID="txtScore" runat="server"></asp:TextBox>
                             </ItemTemplate>
                         </asp:TemplateField>
                        </Columns>
                    </asp:GridView>

想到了其实很简单

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cfreez/archive/2008/09/18/2945564.aspxhttp://blog.csdn.net/cfreez/archive/2008/09/18/2945564.aspx

你可能感兴趣的:(c,function,server,asp,textbox)