Field Formular
/Numerical NEW Bootstrap theme
Set formular on fields Edit a record adjust unit price and see as total is calculated
HIDE CODE
<?php
// Get an instance of the Xcrud class
$xcrud = Xcrud::get_instance();
// Set the table to work with
$xcrud->table("orderdetails");
// Define which columns to display in the table
// These columns will be shown in the table view
$xcrud->columns("orderNumber,productCode,orderLineNumber,quantityOrdered,priceEach,total");
// Define which fields are available for data entry or editing
// These fields will be shown in the form view for adding/editing records
$xcrud->fields("orderNumber,productCode,orderLineNumber,quantityOrdered,priceEach,total");
// Set up a relation between the 'officeCode' field in the 'orderdetails' table
// and the 'officeCode' and 'city' fields in the 'offices' table
$xcrud->relation("officeCode", "offices", "officeCode", "city");
// Set up a dynamic formula for the 'total' field
// When the 'onmouseout' event is triggered on the 'quantityOrdered' or 'priceEach' fields,
// the 'total' field will be calculated as quantityOrdered * priceEach and rounded to one decimal place
$xcrud->set_formular(
"total",
'parseFloat({quantityOrdered}*{priceEach}).toFixed(1)',
"onmouseout",
"quantityOrdered,priceEach"
);
// Make the 'total' field readonly
// This means the 'total' field cannot be edited by the user
$xcrud->readonly("total");
// Change the label of the 'total' field to 'Total'
$xcrud->label("total", "Total");
// Render the Xcrud instance to display the table and form
// This will output the HTML needed to display the table and form on the web page
echo $xcrud->render();
?>
Warning: Undefined variable $bool in /home/mixcprassd/public_html/backendDemo/xcrud/xcrud.php on line 1165
Orderdetails
| # | Ordernumber | Productcode | Orderlinenumber | Quantityordered | Priceeach | Total | |
|---|---|---|---|---|---|---|---|
| 1 | 10100 | S18_1749 | 4 | 3534 | 136 | 0 | View Edit Remove |
| 2 | 10100 | S18_2248 | 2 | 53 | 55.09 | 0 | View Edit Remove |
| 3 | 10100 | S18_4409 | 4 | 22 | 75.46 | 0 | View Edit Remove |
| 4 | 10100 | S24_3969 | 1 | 49 | 35.29 | 0 | View Edit Remove |
| 5 | 10101 | S18_2325 | 4 | 25 | 108.12 | 0 | View Edit Remove |
| 6 | 10101 | S18_2795 | 1 | 26 | 167.09 | 0 | View Edit Remove |
| 7 | 10101 | S24_1937 | 3 | 45 | 32.53 | 0 | View Edit Remove |
| 8 | 10101 | S24_2022 | 2 | 46 | 44.35 | 0 | View Edit Remove |
| 9 | 10102 | S18_1342 | 2 | 39 | 95.55 | 0 | View Edit Remove |
| 10 | 10102 | S18_1367 | 1 | 41 | 43.13 | 0 | View Edit Remove |