Dynamically Adding Drop Downs

SweetGuitar 10 Oct, 2012
Only started using Chronoforms yesterday and it's been a great help to my assignment!

My basic question is this: is there any way to dynamically add more drop down lists?

Background: In my situation I'm creating a website for my lecturer to manage programming contests in our region, the contestants and teams in those contests too. The ability to upload/download sample and judge in/out files is also included (just like you would do in the ACM Contest if you've heard of it).

Question (more detailed): I have a form for adding contestants to a team. I've designed the database to allow for an unlimited number of contestants per team. Is there any way so that after selecting one contestant in a drop down list to add to the team, another one could appear below? Essentially I'd be able to add multiple records into the database at the same time?

Any help would be much appreciated! πŸ˜€
Regards,
Adam
GreyHead 10 Oct, 2012
Hi Adam,

I'm sure that is it possible :-)

The simplest way if it's just a drop-down selection for each team member would be to make the select drop-down multiple so that several names can be selected at once. You'd then need some Custom Code after the form is submitted to format the result for saving.

If there is more than just the name it's still possible but gets more complicated.

Bob
SweetGuitar 10 Oct, 2012
Cheers for the fast reply!
That would definitely do the job, cheers!

Custom Code wise, would that be done instead of a DB Save? Would I just execute my own insert statements in the custom code or is there a simpler way?

Absolutely amazing extension tooπŸ˜€

Adam
SweetGuitar 10 Oct, 2012
Two more questions sorry:

a) Is there any way to load multiple table fields into one text key for a drop down box? I.e. first_name + ' ' + last_name

b) Can ChronoForms store and retrieve data to and from a BLOB field? Due to each file only being a few kb and the large quantity of them, I was thinking that storing them as BLOB would be better than storing on the server as files.

Regards,
Adam
GreyHead 10 Oct, 2012
Hi Adam,

How to do the database saves depends on your table structure. The ChronoForms DB Save will work but really only of each table has a single record written to it. To write multiple records I'd write my own SQL in a Custom Code action.

There's no built in way of joining two fields in a drop-down but again it's pretty easy to do with a Custom Code action. You just need to make sure that you get a suitable array of results in the $form->data array to populate the drop-down. Please see this FAQ for some suggestions on populating drop-downs. It doesn't have exactly the code you need though.

In theory I guess you could save in BLOBs but I've never done it.

Bob
This topic is locked and no more replies can be posted.