Hi,
you can out the the generated ID from code by using txtTotal.ClientID
property of the control and outputting it to the script (either generate
entire script block in code or append tthe id using <%=txtTotal.ClientID%>
block in middle of the script.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"John Mason" <wollondilly@hotmail.com> wrote in message
news:usmq7BKPFHA.2788@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi,
>
> I am trying to figure out how to do a client-side calculation based on
> textbox values, using asp.net, without performing a postback.
>
> I have 2 textboxes...
>
> <asp:textbox runat="server" CssClass="ddclass" ID="txtTotal"
> onBlur="calculate()" />
>
> <asp:textbox runat="server" CssClass="ddclass" ID="txtAmount" />
>
>
> I have used the following Javascript code...
>
> <SCRIPT TYPE="text/javascript">
> <!--
> function calculate() {
> var Amount;
> Amount = (document.forms["_ctl0"].elements[5].value * 0.075);
> Amount = CovCom.toFixed(2);
> document.forms["_ctl0"].elements[6].value = Amount;
>
> };
> -->
> </script>
>
> However, sometimes the element number changes, and calculation does not
> occur. Is there a way of referring to the textbox ID's in the Javscript
> code?
>
> Has anyone performed client-side calculations in asp.net without
> postback? Is there a better way than doing the above?
>
> Appreciate any help!!
>
> Thanks,
>
> John.
>
>
>
>
>
> *** Sent via Developersdex
http://www.developersdex.com ***[/color]