0

I am writing a javascript function like this, my problem is I can pass the values (quantity and price ) retrieve amount, print the amount in label and textbox(same values), but label is working and in textbox value after selecting another operation first value is coming.

What is the problem in this code or any modification needed (I am using OnChange event) and some times it is working with IE browser (but adding the master page doesn't work on any browser)

function Total(Quantity,Price,Amt)
{
var Quan=document.getElementById(Quantity).value;
var Pric=document.getElementById(Price).value;
var tt=document.getElementById('lblTotal').innerHTML;

if(tt=='')
{
   tt=0;
}
if(Quan=='')
{
}
else
{
 var cc1=document.getElementById(Amt).value;
if(cc1!='')
{
  tt=parseFloat(tt)-parseFloat(cc1);
}
document.getElementById(Amt).value=(parseFloat(Quan)*parseFloat(Pric)).toFixed(2);
var cc=document.getElementById(Amt).value;
//document.getElementById(Amt).value=cc.toFixed(2);
document.getElementById('lblTotal').innerHTML = (parseFloat(tt)+parseFloat(cc)).toFixed(2);
document.getElementById('h1').value=document.getElementById('lblTotal').innerHTML;
document.getElementById("<%= TextBox1.ClientID %>").innerText =document.getElementById('lblTotal').innerHTML;
}
0

1 Answer 1

1

Change this line

document.getElementById("<%= TextBox1.ClientID %>").innerText =document.getElementById('lblTotal').innerHTML;

to

document.getElementById("<%= TextBox1.ClientID %>").value =document.getElementById('lblTotal').innerHTML;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.