C
chumley
I'm having trouble generating onchange event code for a simple order
form housed in a datagrid.
This takes product items from sql database, whereas user can enter
quantity (originally set to 25) of cards they want to order (the
textbox id is txtQty). if they order 50 (so if they order 25 to 49,
the price would stay the same for the lot), the subtotal for that
given product will change another 15 dollars greater., so the formula
for the price wouldnt be product * price, but "if qty = qty + 25 then
subtotal = price + 15". Then the button click event would add the
subtotals to a grand total.
I cannot coordinate the adequate javascript that would fit with this
type of scenario, given that this is all predicated on each product
coming from the database;i'm wondering if there is another good source
i can be directed to that would show helper functions in the code
behind or header subs to calculate the onchange (or textOnchange)
event of the textbox.
<form name="mydgrid" runat="server">
<aspataGrid id="dgProducts" runat="server"
AutoGenerateColumns="False" CellPadding="4"
HeaderStyle-BackColor="teal"
HeaderStyle-ForeColor="White"
HeaderStyle-HorizontalAlign="Center"
Font-Name="Trebuchet MS"
HeaderStyle-Font-Bold="True"
ShowFooter="true"
ShowHeader="true"
<Columns>
<asp:BoundColumn HeaderText="ID" DataField="pID" />
<asp:BoundColumn HeaderText="Name" DataField="proname" />
<asp:TemplateColumn HeaderText="QTY"><ItemStyle
BackColor=GhostWhite />
<ItemTemplate>
<asp:TextBox ID="txtQty" name="txtQty"
runat="server" size="5px" Text='25' onChange="qtycg(this.form)">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Price<br>1 Ink</br>"
DataField="UnitPrice"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:$#,###.##}" />
<asp:BoundColumn HeaderText="Price<br>2 Ink</br>"
DataField="UnitPrice2C"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:$#,###.##}" />
<asp:TemplateColumn HeaderText="Subtotal">
<ItemTemplate >
<asp:TextBox id="SubTotal" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "UnitPrice")%>'></asp:TextBox>
</ItemTemplate>
<FooterTemplate> <asp:Label id="lblGrandTotal" Runat="server"
Text='Grand Total:'></asp:Label> <br></br>
<asp:TextBox ID="Total" Runat="server"
size="5px" onFocus="this.form.elements[0].focus()"></asp:TextBox>
<br><asp:Button id=btnSave align=center CommandName="Save" Text=Save
runat=server />
<asp:Button ID="btnReset" align=center Text=Reset runat=server /
</asp:TemplateColumn>
</Columns>
</aspataGrid>
</form>
ThANKS IN advance for any help!
chumley
form housed in a datagrid.
This takes product items from sql database, whereas user can enter
quantity (originally set to 25) of cards they want to order (the
textbox id is txtQty). if they order 50 (so if they order 25 to 49,
the price would stay the same for the lot), the subtotal for that
given product will change another 15 dollars greater., so the formula
for the price wouldnt be product * price, but "if qty = qty + 25 then
subtotal = price + 15". Then the button click event would add the
subtotals to a grand total.
I cannot coordinate the adequate javascript that would fit with this
type of scenario, given that this is all predicated on each product
coming from the database;i'm wondering if there is another good source
i can be directed to that would show helper functions in the code
behind or header subs to calculate the onchange (or textOnchange)
event of the textbox.
<form name="mydgrid" runat="server">
<aspataGrid id="dgProducts" runat="server"
AutoGenerateColumns="False" CellPadding="4"
HeaderStyle-BackColor="teal"
HeaderStyle-ForeColor="White"
HeaderStyle-HorizontalAlign="Center"
Font-Name="Trebuchet MS"
HeaderStyle-Font-Bold="True"
ShowFooter="true"
ShowHeader="true"
<Columns>
<asp:BoundColumn HeaderText="ID" DataField="pID" />
<asp:BoundColumn HeaderText="Name" DataField="proname" />
<asp:TemplateColumn HeaderText="QTY"><ItemStyle
BackColor=GhostWhite />
<ItemTemplate>
<asp:TextBox ID="txtQty" name="txtQty"
runat="server" size="5px" Text='25' onChange="qtycg(this.form)">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Price<br>1 Ink</br>"
DataField="UnitPrice"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:$#,###.##}" />
<asp:BoundColumn HeaderText="Price<br>2 Ink</br>"
DataField="UnitPrice2C"
ItemStyle-HorizontalAlign="Right"
DataFormatString="{0:$#,###.##}" />
<asp:TemplateColumn HeaderText="Subtotal">
<ItemTemplate >
<asp:TextBox id="SubTotal" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "UnitPrice")%>'></asp:TextBox>
</ItemTemplate>
<FooterTemplate> <asp:Label id="lblGrandTotal" Runat="server"
Text='Grand Total:'></asp:Label> <br></br>
<asp:TextBox ID="Total" Runat="server"
size="5px" onFocus="this.form.elements[0].focus()"></asp:TextBox>
<br><asp:Button id=btnSave align=center CommandName="Save" Text=Save
runat=server />
<asp:Button ID="btnReset" align=center Text=Reset runat=server /
</FooterTemplate></br>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
</form>
ThANKS IN advance for any help!
chumley