Login Retreive lost passwordRegister
Search

Forum Index / General / Auto calculation

[ This topic is solved ]

  Debasish Mondal 18 May 10 / 12:26  
We are using Formhandler in our site, we want to use a small calculation there. We have an Order form where visitor will input their details. We want to place 2 fields there next to each other. One for the number of items ordered (left) and one for the amount to be payed (right), So if they order 2 pieces the amount field will automatically update as 150 (75x2), then they press "submit" button.

Is there any functions or process to do such? We did such for manual form, never with FormHandler, can anyone help us?

  Johan Wiegel (Admin) 18 May 10 / 12:34  
You can use the extra argument of a field to add javascript like you did in manual forms.

  Debasish Mondal 19 May 10 / 05:36  
Hi

I want to use following function on onFocus of the textfield, Pls, confirm how I can do that. Its very much required for me to do, Pls, help.

Textfield :-
$form->textField( "Quantity", "qty", FH_STRING);

Function :-
<script language="javascript">
function startRood()
{

interval = setInterval("calc()",1);

}
function calc()
{
one = document.getElementById("qty").value;
two = 75;
showval = (one * 1) * (two * 1);
showval = parseFloat(showval).toFixed(2);
document.getElementById("amount").value = showval;
}
</script>

  Johan Wiegel (Admin) 19 May 10 / 07:52  
that would be someting like:

<?php
$oForm
->TextField('Quantity''qty'FH_STRINGnullnull'onfocus="startRood()"');
?>

  Debasish Mondal 19 May 10 / 08:46  
Hi John,

Thank you very much, it solved now.

  Top


powered by PHP-GLOBE   © 2004 - 2010 FormHandler. All rights reserved.   -   Open source license