Hello everybody.
I have a "budget" table with a "human_resource" field, a "hours" field, a "hourly_cost" field and a "allocated_quote" field
The "human_resource" field and the "hourly_cost" field are lookup fields that point to the "name" and "h_cost" fields of the "human_resources" table respectively. In the "budget" table the "hourly_cost" field is filled in automatically when the "human_resource" field is selected.
I would like to create a javascript code for the "budget" table which, after filling in the "human_resource" and the "hours" field, multiply the "hourly_cost" value by the "hours" value and insert the result in "imputed_quote".
The "imputed_quote" field should however also be editable manually after the automatic compilation.
Can someone help me?
THANK YOU!
Fabiano
Fill a field with the result of a javascript calculation
Re: Fill a field with the result of a javascript calculation
HI!
I try this code but it not work!
I suspect tha the problem is that the hourly_cost field is a lookup field taked from the cost_for_hour field of the hourly_costs table.
So I cannot find the right code to make my code work.
Anyone can help me?
THANK YOU!
Fabiano
I try this code but it not work!
Code: Select all
$j(function () {
var update_imputed_quote = function () {
var v_hourly_cost = $j('#hourly_cost').val();
var v_hours = $j('#hours').val();
var v_imputed_quote = v_hourly_cost * v_hours;
$j('#imputed_quote').val(v_imputed_quote);
}
$j('#hourly_cost' ).on('change', update_imputed_quote);
$j('#hours' ).on('change', update_imputed_quote);
});
So I cannot find the right code to make my code work.
Anyone can help me?
THANK YOU!
Fabiano