populating hidden field with a sum
With Data Assist is it possible to populate a hidden field with the total of two manual input text fields before inserting?
With Data Assist is it possible to populate a hidden field with the total of two manual input text fields before inserting?
you would need to use javascript to assign the value on submit.
I assume you want to insert the sum to a database column?
instead of using javascript to set a hidden element, do the math server side to sed the hidden element.
for example if you have form elements named txt1, txt2 and txtSum, add the following at line 1 of the page:
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$txt1 = (isset($_POST["txt1"]))?intval($_POST["txt1"]):0;
$txt2 = (isset($_POST["txt2"]))?intval($_POST["txt2"]):0;
$txtSum = $txt1 + $txt2;
$_POST["txtSum"] = $txtSum ;
}
?>
bear in mind that this code assumes the use of integers, if you are using floating point numbers, change intval to floatval.
Thank you. I was thinking there may be a way to do it right with the DataAssist tools, but that works as well.
Again, I know sometimes I am very hard on you guys, but no one can deny the tech support service you guys provide. Usually a pretty good answer and in a timely fashion. Thanks again.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.