select form field from dynamic ( database )
Permalink
This is probably a simple question that has probably been asked before
but I can't seem to find a straight forward solution in the forums. maybe my question is too simple.
I want to be able to have a dashboard select dropdown prefill the options for a select fields on a dashboard Add page - i.e.
so that when someone is filling out a form the choices are available.
I have coded this kind of form many times in Coldfusion.
But
In Concrete - I have searched and seen people using this for page attributes and such, but it is not clear where to put the code in a form (controller, view, model ) as I need to use the same choices many times on a form add in dashboard pages. The choices are stored in another database table ( than the one that is being added when form is saved.)
The page I am working on is to put scores for games
( select choices from database table "Teams")
so game 1 would have
game 1
G1team1 ( dropdown1 select with all teams for options ) vs
G1team2 ( dropdown2 select with all teams for options )
game 2
G2team1 ( dropdown1 select with all teams for options ) vs
G2team2 ( dropdown2 select with all teams for options )
and so on
Click Add saves database table "Games"
Could I put a select in a function then just call it each time needed?
It seems to me that I should be able to use a funtion to get the array and then just called the function for every select box option.
Or do I have to type the same call over and over down the dashboard view page?
Any help would surely be appreciated
but I can't seem to find a straight forward solution in the forums. maybe my question is too simple.
I want to be able to have a dashboard select dropdown prefill the options for a select fields on a dashboard Add page - i.e.
so that when someone is filling out a form the choices are available.
I have coded this kind of form many times in Coldfusion.
<cfquery datasource="#data# name="query_name"> SELECT Display, Value FROM YourTable ORDER BY Whatever </cfquery> then <select name="whatever"> <cfoutput query="query_name"> <option value="#Value#">#Display#</option> </cfoutput> </select>
But
In Concrete - I have searched and seen people using this for page attributes and such, but it is not clear where to put the code in a form (controller, view, model ) as I need to use the same choices many times on a form add in dashboard pages. The choices are stored in another database table ( than the one that is being added when form is saved.)
The page I am working on is to put scores for games
( select choices from database table "Teams")
so game 1 would have
game 1
G1team1 ( dropdown1 select with all teams for options ) vs
G1team2 ( dropdown2 select with all teams for options )
game 2
G2team1 ( dropdown1 select with all teams for options ) vs
G2team2 ( dropdown2 select with all teams for options )
and so on
Click Add saves database table "Games"
Could I put a select in a function then just call it each time needed?
It seems to me that I should be able to use a funtion to get the array and then just called the function for every select box option.
Or do I have to type the same call over and over down the dashboard view page?
Any help would surely be appreciated