我有一个输入框和隐藏字段。我想将文本框的值传递给隐藏字段。如何实现这一目标。 [英] I have an input box and hidden field. I want to pass the value of text box to hidden filed. How to achieve that.

查看:80
本文介绍了我有一个输入框和隐藏字段。我想将文本框的值传递给隐藏字段。如何实现这一目标。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< asp:TextBox ID =txtHoursorAmountrunat =serverstyle =width:80px;/>

< input type =hiddenname =hdnAmountorHours id =hdnAmountorHoursrunat =server/>

<asp:TextBox ID="txtHoursorAmount" runat="server" style="width: 80px;"/>
<input type="hidden" name="hdnAmountorHours" id="hdnAmountorHours" runat="server" />

推荐答案




这是怎么回事您可以使用Javascript来解决问题。



Hi
This is how you can use Javascript to solve the problem.

<asp:TextBox ID="txtHoursorAmount" runat="server"  onblur="transferValue()"/>
            <input type="hidden" name="hdnAmountorHours" id="hdnAmountorHours" runat="server" />

< br $>


脚本是





script is

<script type="text/javascript">
        function transferValue()
        {
            var inputVal = document.getElementById("txtHoursorAmount").value;
            document.getElementById("hdnAmountorHours").value=inputVal;
            alert(inputVal);
        }
    </script>



好​​运


Good Luck


在上面的解决方案中





更改

var inputVal = document.getElementById(txtHoursorAmount)。value;





in the above solution


change
var inputVal = document.getElementById("txtHoursorAmount").value;

To
var inputVal = document.getElementById('<%=txtHoursorAmount.ClientID %>').value ;





,设定值与上述相同.......



and set value as same as above.......


这篇关于我有一个输入框和隐藏字段。我想将文本框的值传递给隐藏字段。如何实现这一目标。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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