Updating Field of Subform after Selection on the first Field
Posted: Fri Sep 10, 2021 9:53 pm
Hi there,
I'm new into Nubuilder and pretty much like it. I'm currently building a databas including forms to ensure batch traceability in an small Food Production.
I have a Form for goods receipt. In this Ihave a Subform for the Items of the receipt. After Selecting the Good (Ware) in the Subform i'd like to have the Field for quantity unit (ME) updatedautomitically.
Based on some articles here in the Forum I tried to do the following:
1. Put this code on the onchange event of the employee select field
2. In your form's Custom Code, add this code:
3. Create a PHP Procedure with the name getMEInfo
This are my Tables:
1. gq_wareneingang (Table for Main Form)
2. gqp_weposten (Table for Subform)
3. Ware (Table where the Goods type is selected from and the ME-Field should be looked up from)
I do not get any Errors on nuDebug.
Would be great, if anyone could help me here.
Thanks in advance,
Ralf
I'm new into Nubuilder and pretty much like it. I'm currently building a databas including forms to ensure batch traceability in an small Food Production.
I have a Form for goods receipt. In this Ihave a Subform for the Items of the receipt. After Selecting the Good (Ware) in the Subform i'd like to have the Field for quantity unit (ME) updatedautomitically.
Based on some articles here in the Forum I tried to do the following:
1. Put this code on the onchange event of the employee select field
Code: Select all
getMEInfo(event);
2. In your form's Custom Code, add this code:
Code: Select all
function fillMEInfo(prefix, gqw_sf000gqp_mengeneinheit) {
$('#' + prefix + 'gqw_sf000gqp_mengeneinheit').val(gqw_sf000gqp_mengeneinheit).change(); // replace 'gqw_sf000gqp_mengeneinheit' with your gqw_sf000gqp_mengeneinheit field object Id
}
function getMEInfo(event) {
var MEId = $('#' + event.target.id).val();
nuSetProperty('MEId', MEId);
var prefix = $(event.target).attr('data-nu-prefix');
nuSetProperty('prefix', prefix);
nuRunPHPHidden('getMEInfo', 0)
}
Code: Select all
function getMEInfo($ware_id) {
// Change the SQL query here:
// $sql = "SELECT war_mengeneinheit FROM `ware` WHERE `ware_id` = ?";
$sql = "SELECT war_mengeneinheit FROM `ware` WHERE `ware_id` = 'gqw_sf000gqp_ware'";
$qry = nuRunQuery($sql, [$ware_id]);
$row = db_fetch_object($qry);
return array(
"gqw_sf000gqp_mengeneinheit" => $row->gqw_sf000gqp_mengeneinheit, // replace gqw_sf000gqp_mengeneinheit with your sql column
);
}
$empInfo = getMEInfo("#MEId#");
$gqw_sf000gqp_mengeneinheit = $empInfo["gqw_sf000gqp_mengeneinheit"];
$name = $empInfo["name"];
$group = $empInfo["group"];
$j = "fillMEInfo('#prefix#', '$gqw_sf000gqp_mengeneinheit'); ";
nuJavascriptCallback($j);
1. gq_wareneingang (Table for Main Form)
2. gqp_weposten (Table for Subform)
3. Ware (Table where the Goods type is selected from and the ME-Field should be looked up from)
I do not get any Errors on nuDebug.
Would be great, if anyone could help me here.
Thanks in advance,
Ralf