Forums

This topic is locked

Calculating on form fields in a repeat region

Posted 05 Feb 2005 15:22:07
1
has voted
05 Feb 2005 15:22:07 Seb Adlington posted:
Hi,

I have a purchase ordering system where a user can add products from a list to a shopping basket - its a trade site and the customer can choose what prices they want for labelling purposes. I need to calculate a %age to show profit on the fly. This is no problem when I have one product on a page, but doesn't work when i have a list of products on screen.

Basically for each product the user can specify, Price, Gross Profit and Quantity - ideally when they type in a price i want the gross profit to autoupdate - also if they type a gross profit, it will work out the price. Like i say i have a script that works singly but in a repeat region it doesn't. I'm thinking I need to call a function from an onchange in the price field, but i can't specify th return fieldname because its repeated!

Any ideas anyone?

Thanks

Seb

Replies

Replied 05 Feb 2005 20:05:01
05 Feb 2005 20:05:01 Vince Baker replied:
You can pass the values from each recordset values to a calculating field i.e. onClick('<%=recordset("price"%>','<%=recordset("grossprofit"%>','<%=recordset("qty"%>') and then receive them in your script e.g.

<script>


function CalculatorProfit(varPrice, varGrossProfit, varQty)

do some calculating

end function

</script>


You can use the form.element(0) to know which element of the form should receive the value by sending the form.element(0etc) to the calculator as well.



Regards
Vince

DMX Manager

Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)

VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting

Reply to this topic