I'm using a Webform, which have 3 fields:
- number of table (enter by user)
- price per table (default webform value)
- total amount to pay (calculation using formula, in webform is hidden field with no default value)
The calculation formula should be:
total amount to pay = number of table * price per table
What I want to do is add in total amount to pay after calculation and submit to webform.
I'm writing the codes as below but it does not work.
function my_module_validate($form, &$form_state) {
if ($form_id == 'webform_client_form_7'){
$form['submitted']['total']['#value'] = $form['submitted']['number_of_tables']['#webform_component']['value'] * $form['submitted']['price_per_table']['#value'];
}
}
Am I writing anything wrong?