This topic is locked

update field in editing

10/3/2007 5:29:28 AM
PHPRunner General questions
E
ellesse author

hello,
I have a page with 4 field: products_id, quantity, price, row_total.
I want see the value of row_total ( price*quantity) in editing in real time and not set it after save command
thank you.

J
Jane 10/4/2007

Hi,
to update field on the Edit page directly you need to edit generated include/commonfunctions.php file:

  1. Locate BuildSelectControl function, find this line:
    echo '<input type="text" name="'.$cfield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'">'

and replace it with this one:

{

if ($field=="Price" || $field=="Quantity")

echo '<input type="text" name="'.$cfield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'" onchange="java script: UpdateSum();">';

else

echo '<input type="text" name="'.$cfield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'">';

}



where Price and Quantity is your actual field names.
2. Then open generated include/jsfunctions.js file in any text editor and add following code at the beginning:

function UpdateSum()

{

document.editform.value_Total.value = document.editform.value_UnitPrice.value*document.editform.value_Quantity.value;

}



where Price and Quantity is your actual field names.