I have two different fields that I need in my form but I only want to display one which the user can change using a selectfield.
I'm using some javascript/ajax to update the the value of the hidden field when the user changes the value of the displayed selectfield. When the user changes the value of the displayed field, I need to update the values of several other fields which need thusing the value of the hidden field.
whatever the user finally selects as the values of these two fields, I need to save both values in a mysql table.
then use them later when the user edits the form data.
Changed at 06 April 07 / 17:50
in the head of one html page, I have the following JS code:
function get_bc_inv(line)
{
var tax_code = document.getElementById(tax_code).value;
<font color="red">ajax.requestFile = 'ajaxphp/get_bc_inv.php?tax_code='+tax_code+'&line='+line;</font>
ajax.onCompletion = show_bc_inv;
ajax.runAJAX();
}
function show_bc_inv()
{
var formObj = document.forms['FormHandler'];
eval(ajax.response);
}
Then I use FH to create the form for the above html page
<?php
$form->HiddenField('tax_rate',$form->getvalue('tax_rate01'));
$form->setvalue('tax_rate',$form->getvalue('tax_rate01'));
$form->selectField("Tax Code", "tax_code01", $the_tax_codes, "dummy_val", true,"","" ,"onchange=\"get_bc_inv('01');calc($inv_format,$p_n,$p_q,$p_r,'$s_k','$s_d','$s_c');\" onkeypress=\"return handleEnter(this, event)\"");
$form->setHelpText("tax_code01", "Select the tax code for this item or Not Taxable");
$form->setErrorMessage("tax_code01", "You must select the tax code for this item or Not Taxable");
?>
the 'ajaxphp/get_bc_inv.php file in part looks like:
I want the user to select the tax_code (I need the tax code to generate reports later on). But I need the tax rate to calculate the tax amount which is done in the calc function