<td width="130" style="WIDTH: 130px">Mastercard
</td>
<td width="21" style="WIDTH: 21px"><INPUT onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Mastercard" type="text" name="Mastercard" runat="server" style="WIDTH: 116px; HEIGHT: 22px" size="14"></td>
When This control, or any of the other 4 I want to update a label control with their total (all 4 added together).
<DIV id=TotalCreditCards
style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px"
ms_positioning="FlowLayout"></DIV></TD>
Thank you for any helpI would put a routine in the onkeypress method to add the values together and display them on the label.
What if I have a routine already in the onkeypress, how can I add another one. Or is there a method for when you leave the text field?
Please take a look at this code. I get 'object expected' error on the page as soon as I update the Lottery text field that does onblur="CreateTotal" If I take out it out then I do not get the error.
Dim Section1Total as Decimal
Sub CreateTotal()
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
If the below text field changes then I want Section1Total to be updated.
<INPUT onblur="CreateTotal" onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Lottery" type="text" name="Lottery" runat="server" style="WIDTH: 116px; HEIGHT: 22px" size="14"></TD>
Then this is the label that Section1Total goes into:
<asp:label id="Total" runat="server"
Text= '<%# Section1Total %>' Width="110px" Height="13px">
Change this:
Sub CreateTotal()
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
To:
Sub CreateTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
Then try executing hte onblur="CreateTotal" again.
And make sure you declared all your form variables properly:
Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
I am assuming they are textbox controls, so they need to be declared by using:
Protected WithEvents DriveOff As System.Web.UI.WebControls.TextBox
Protected WithEvents Lottery As System.Web.UI.WebControls.TextBox
Protected WithEvents drawer As System.Web.UI.WebControls.TextBox
Protected WithEvents OtherAs System.Web.UI.WebControls.TextBox
HTH
Ah, just noticed you were using an HTML text control and not a web control. In that case you must declare them by using the following:
Protected WithEvents DriveOff As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Lottery As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents drawer As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents OtherAs As System.Web.UI.HtmlControls.HtmlInputText
It already said that my HTML text controls were declared, so I did not include those lines of code but the rest I did word for word. I even added a button and have the onclick="CreateTotal"
Here is my vbscript
Sub CreateTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub
and the other Lottery control has
<INPUT onblur="CreateTotal" onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Lottery" style="WIDTH: 116px; HEIGHT: 22px" type="text" size="14" value="0" name="Lottery" runat="server"></TD>
When I click off Lottery textbox I get
Line: 507
Char: 1
Error 'CreateTotal' is undefined
when I click on the button I get the same error. Line 507 - doesn't not point to the correct place where 'CreateTotal' was called.
Thanks for the suggestions, any other ideas.
Can you post line 507?
0 comments:
Post a Comment