如何清除隐藏字段的值 [英] How do I clear the value of hidden filed

查看:117
本文介绍了如何清除隐藏字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有隐藏字段和文本框控件。我正在设置文本框中隐藏字段的值,我有一个隐藏值的管道,它是文本框的值,另一个是来自jquery函数的值。每当我单击警告框上的确定按钮并在文本框中输入新值时,它将附加到具有额外管道的旧值。我的问题是每当我在文本框中输入新文本时如何清除隐藏字段的值。





  function  transferValue(){

var inputVal = document .getElementById(' <%= txtHoursorAmount.ClientID%>').value;
document .getElementById(' <% = hdnAmountorHours.ClientID%>')。value = document .getElementById(' < span class =code-string><%= hdnAmountorHours.ClientID%>')。value + | + inputVal;
alert( document .getElementById(' < ;%= hdnAmountorHours.ClientID%>')。value);
}

解决方案

因此你正在使用jQuery,尝试如下。



注意:这只是一个示例。根据您的应用调整它。

 


( #您的隐藏场-ID)VAL( '');


Hello,

I've a hidden field and a textbox control. I'm setting the value of hidden field from textbox and I;ve a pipe for hidden value which is the value of textbox and another value from jquery function. whenever i click the ok button on alert box and enter a new value in textbox it is attached to old value with extra pipe. My question is how to clear the value of hidden field whenever I enter new text in textbox.


function transferValue() {

            var inputVal = document.getElementById('<%=txtHoursorAmount.ClientID %>').value;
            document.getElementById('<%=hdnAmountorHours.ClientID %>').value = document.getElementById('<%=hdnAmountorHours.ClientID %>').value + "|" + inputVal;
            alert(document.getElementById('<%=hdnAmountorHours.ClientID %>').value);
        }

解决方案

Hence you're using jQuery,try is as below.

Note:This is just a sample.Adjust it according to your app.


("#your-hidden-field-id").val('');


这篇关于如何清除隐藏字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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