Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.


JavaScript
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);
        }
Posted
Updated 13-Apr-14 5:52am
v2

1 solution

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('');
 
Share this answer
 
v2
Comments
Member 10740414 13-Apr-14 12:18pm    
Where should I put this?
Member 10740414 13-Apr-14 12:19pm    
At start of function?
Sampath Lokuge 13-Apr-14 12:19pm    
Yes.
Member 10740414 13-Apr-14 12:22pm    
Thanks Sampath.
Sampath Lokuge 13-Apr-14 12:26pm    
You're warmly welcome. :) If this is the answer,Plz accept it.It'll help for the users who'll have the same issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900