1

我无法复制或自动绑定到第二个文本框。我需要处理哪个事件,onkeyup或者onblur

这是我的代码:

<script type="text/javascript">    
    function OneTextToother()   
    { 
    var first=document.getElementById(txtQuantity).value;    
    document.getElementById(txtQuantity1).value=first; 
    }     
</script>

<asp:GridView ID="gvOrder" runat="server" OnRowDataBound="gvOrder_RowDataBound">       
<Columns>              
<asp:TemplateField>                   
<ItemTemplate>                    
<asp:TextBox ID="txtQuantity" runat="server" onkeyup="javascript:OneTextToother();" >
</asp:TextBox>                    
</ItemTemplate>                                
</asp:TemplateField>     
<asp:TemplateField>                  
<ItemTemplate>                
 <asp:TextBox ID="txtQuantity1" runat="server" ></asp:TextBox>               
</ItemTemplate>                              
</asp:TemplateField>          
</Columns>        
</asp:GridView>
4

1 回答 1

1

您可以使用Client Id property

<%# ((GridViewRow)Container).FindControl("txtQuantity1").ClientID %>

所以

var first = document.getElementById('<%# ((GridViewRow)Container).FindControl("txtQuantity").ClientID %>');

document.getElementById('<%# ((GridViewRow)Container).FindControl("txtQuantity1").ClientID %>').value=first;
于 2012-10-09T14:44:31.683 回答