add form - populate dropdown dependant on other elements of form

shortbow

New Member
Hi,

I've searched in the wiki and the forum but havent found anything about this.

I have an dropdown element populated by the result of a database join.
I would like to filter the results by adding a SQL where clause refering to the value of 2 other elements in the said form, is it possible? if so what would be the sintax?

at the moment the where clause (tested directly against the database is) :
where j_equip.equip_id= j_marc.equipamento_id
and j_marc.data_incio > <element value(date)>
and j_marc.data_fim < <element value(date)>

and the full element name I pretend to use to filter the results are:
j_marc_date_start
j_marc_date_end

thanks
 
I've moved this thread to Standard.

Is there some reason you can't use a join element for this? Which gives you the option to add a WHERE clause using placeholders for element values.

-- hugh
 
Thanks!
You are right.
I only needed to put in the databasejoin element in the data-where -> join, the query:

{thistable}.eq_id NOT IN (select eq_id from jmarc where DATE_FORMAT(dinicio,'%Y-%m-%d') <= DATE_FORMAT('{jmarc___data_incio}','%Y-%m-%d') and DATE_FORMAT(dfim,'%Y-%m-%d') >= DATE_FORMAT('{jmarc___data_fim}','%Y-%m-%d') )
order by tipo_id

and it populate the dropbox only with the records I wanted.
After that I found I could set the element to re-run if some other elements changed and all was good with the world.

Now I'm gona have to find out how to make some additional database inserts\updates, I'm guessing with PHP, when the users submits the form, but thats today challenge :p
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top