Page 1 of 1
How can I access/read a field from the input form?
Posted: 2023-05-05 22:19
by compusoft
Hi
Is there a way that I can read or access a field that the user is typing, to incorporate its value in a search?
for example, this is my query for the lookup Sites
SELECT `Sites`.`id`, `Sites`.`Description` FROM `Sites` WHERE `Sites`.`id` NOT IN (SELECT `Reservation`.`SITIO` FROM `Reservation` WHERE `Reservation`.`DATE` = '2023-05-05')
It works fine, but only for the date '2023-05-05'. What I need is to replace this constant for the value than the user is introducing in Reservation.Date at the time of the capture
Re: How can I access/read a field from the input form?
Posted: 2023-05-06 07:47
by pbottcher
Hi,
can you be a bit more specific on how you want this to happen. Shall it be at the time the user enters some data, or when the user saves a record?
In general you can access the entered data via the $_POST, $_GET or $_REQUEST arrays.
If you use the standard Appgini form for date input you will need to gather the 3 fields representing the day, month and year and put them together.
Re: How can I access/read a field from the input form?
Posted: 2023-05-06 18:21
by compusoft
Hi pböttcher
Yes. It must be before the user saves the record

- Screen1.jpg (46.48 KiB) Viewed 4420 times
In this screeen, if the user change the value on field Reserva.Date (Fecha) the lookup query muste change to show only the sites that are not reserved on that date.
So, the field Reserva.Date it is conformed by 3 differente fields in AppGini? How they are named? And, how can I access their valies?
Thanks for your help!
Re: How can I access/read a field from the input form?
Posted: 2023-05-26 19:30
by compusoft
Update:
Using the following script I can now read the date selected by the user and store it in the Calculated variable
<scritp>
$j(function(){
$j('#Fecha-dd, #Fecha-mm, Fecha').change(function(){
var y = $j('#' + 'Fecha').val();
var m = $j('#' + 'Fecha-mm').val();
var d = $j('#' + 'Fecha-dd').val(); // Reading the data in DV
if (m < 10) {
m = '0' + m; // Formating
}
if (d < 10) {
d = '0' + d; // Formating
}
stfecha = y + '-' + m + '-' + d; // Now stfecha = 'YYYY-MM-DD'
$j('#Calculado').val(stfecha); // Puting stFecha in RESERVAS.CALCULADO (A field in the DV)
});
});
</script>
I made Calculado as a text field in the database, to be able to read it and use it in the next lookup advanced query

- lookupQuery2.jpg (104.87 KiB) Viewed 4260 times
But it is not working. In fact, if I put an empty string instead of 'RESERVAS.CALCULADO' the efect is the same
What I'm doing wrong?
Re: How can I access/read a field from the input form?
Posted: 2023-05-26 19:37
by compusoft
Ups
In the previous screen, I use `RESERVAS`.`FECHA` = `'RESERVAS`.`CALCULADO`' (with double quote)
I tried also `RESERVAS`.`FECHA` = `RESERVAS`.`CALCULADO` (single quote) but the result is the same