Login Retreive lost passwordRegister
Search

Forum Index / General / Passing a "hidden" field to the table

[ This topic is unsolved! ]

  gene 18 March 07 / 03:34  
The manual says to use the setValue function instead of the HiddenField function to add a value to a table.

But I don't want to display the field (I'm updating via Ajax)

So I used the following.

$form->setValue('code_10',"");
$form->HiddenField('code_10',"");

Is there a better way to do it...???


.

  Teye Heimans (Founder) 20 March 07 / 10:38  
No, the manual says that you should use AddValue instead. Not setValue. Maybe this solves the problem?

  gene 20 March 07 / 13:14  
Changed at 22 March 07 / 11:25
yes. you are correct. My statement was based on memory which at best is very faulty. :-)

however, by using the hiddenfield/setvalue combination described above, FH seems to add the field during the INSERT/UPDATE process.

While the field is not displayed, I do need it while the form is on the screen and I need the value to be saved to the table.

just wondering if you had any thoughts on that



.

  Teye Heimans (Founder) 23 March 07 / 10:22  
I'm sorry, but i don't understand the problem.. could you explain it again?

  gene 28 March 07 / 22:27  
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.

  Teye Heimans (Founder) 06 April 07 / 10:03  
Hi Gene,

Sorry for my late response. I still don't see the problem. What you describe is still very possible, isnt it?

  gene 06 April 07 / 14:45  
I'm just trying to find out what you think of what I did to solve a way I did something in FH...???

.

  Teye Heimans (Founder) 06 April 07 / 14:50  
can you submit some code as example?

  gene 06 April 07 / 17:49  
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:

if($inf = mysql_fetch_array($res)){

    echo "formObj.tax_code".$_GET['line'].".value = '".$inf["bc_sales_tax_code"]."';\n";
    echo "formObj.tax_rate".$_GET['line'].".value = '".$inf["tc_rate"]."';\n";
}


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


.

  Top


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