Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate VAT without doing a PostBack

Status
Not open for further replies.

monkeymagic2222

Technical User
May 13, 2002
78
GB
Hi,

I have 3 textboxes within a Details View, Unit Cost, VAT and Total.

All I want to do is, after a user has entered a figure into the Unit Cost to automatically calculate the VAT (unit cost * 17.5%) then populate the unit cost + VAT in the Total textbox.

Is this possible without doing a postback, i.e. maybe using something like JavaScript's OnChange?

Thanks in advance.
 
you could also put it into a update panel so that everything doesn't get posted back and do your calculation as normal.

To go where no programmer has gone before.
 
for textbox1:

txtbox1.Attributes.Add "onblur", "Calc()")

on asp page you would have:

<script type="text/javascript" language="javascript">

function Calc()
{
var value;
var Mins;

var = document.getElementById('<%=txtbox1.ClientID %>').innerText;

//do your math with the var then

document.getElementById('<%=txtbox2.ClientID %>').innerText = var;
}
</script>


is that what your looking for
 
Hi blar9,

Yes thats pretty much what I was looking for. Using a combination of:

Page.ClientScript.RegisterClientScriptBlock and

CType(DetailsView1.FindControl("TextBox4"), TextBox).Attributes.Add("onblur", "return Calc();") I have achieved what I wanted.

Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top