PDA

View Full Version : claculate form


andyc209
04-24-2006, 12:22 PM
I have a form which when users enter values into any field it automatically calulcates what they have entered through a calculation and puts the running total into another form field. However I have a postcode/zipcode field and based on what they enter there it will do one calculation or another. i.e. if they live in one area the total is multiplied by 120% and if they live in another area it is multiplied by 100%. The area they live in is based on the first 2 characters of their code....

i.e. if they enter AB1 2DE then the AB tells us it needs to be multiplied by 120%

if they enter DE3 4ST then the DE tells us it needs to be multiplied by 100%

I was thinking I could use some script to put the first 2 characters into a hidden field based on what they enter...how can a add just these first 2 characters into a hidden field?

Also how can I make the calculate form script know which percentage to use.

The calculation script is for one of the form elements is below, it appears on all the form elements so that as they enter data it updates the total as they go along.


onKeyUp="YY_CalculateForm('document.form1','annual','2','\(','\(','\(','#value','*','0.07','\)','+','\(','#us ea','*','11','\)','\)','*','#homecnt','\)','*','\(','\(','\(','\(','#usea','-','#useb','\)','*','1','\)','+','\(','#useb','*','1.20','\)','\)','/','#usea','\)','*','1','*','#member');YY_CalculateForm('document.form1','monthly','2','#annual','*', '0.1')"

Ultimately I need the #homecnt to know if it should be 120% or 100% based on the entered postcode

andyc209
04-24-2006, 03:06 PM
this function posts the data to a hidden field...

function copyData(from,to) { to.value = from.value; }

can I make it jsut post the first 2 characters