CalcBuilder Forum

Possible to select files from site using a drop down?

User TheFencepedia 2025-05-21 16:21:01

Hi there,

We've had someone ask us if it's possible for them to store a file on our site, and then use the drop downs on Calcbuilder to insert it into a calculator.

So, instead of uploading a file, they would select from a list of files stored somewhere on our site, and load that one from there.

Thanks so much for any suggestions you might have!

Moonsoft support 2025-05-22 09:36:12

Hi,
the option list can't be filled using a file list from a directory using the default configuration parameters, but if you have some knowledge of php+js or the help of a developer, we have found a way that you could build such a function. At the calculator, you can create the option list but without any option , or maybe a default option saying --select file-- or --loading files--

Then create a new calculator and publish it at the same page. This calculator won't have any input fields, and all the sections should be hidden. It should execute once the page is loaded (checking preferences->Throws calculate on init page). This calculator will be in charge of recovering the list of files from your folder, and output it to the page using any hidden section, maybe as a json list, for ex. Then at the event js->executed after calculation, you can use this list of files to create the options for the main calculator input field, adding new options dynamically, using jQuery. From here your main calculator can work normally, and you can recover the new value selected at calculation time.

Again, this is a complex solution that requires some coding, please let us know if you'd prefer us to build it and we'll evaluate time needed.

Hope this helps, regards
Silvia Martín
Moonsoft Team

User TheFencepedia 2025-05-22 18:50:12

Hi,

We were thinking of just using the Sql Query option in the options list, and then store the information in a specific table?

That should work, right?

Moonsoft support 2025-05-23 12:32:49

Hi,
right, our solution above solves the problem of 'reading' a server folder to build the options dynamically. But if you are able to store the information of the options in an specific table in advance, then you can configure the option list to recover them from that table to build the available options at the combobox.

For ex, if you have the options stored in a table 'mytable' at the column 'mycolumn', you can configure the sql query option as

select mycolum as id, mycolumn as value from mytable

(we recover both id and value to set the 'value' and 'text' for each option, and they can be the same as in this example)

If you plan to use a separated Calcbuilder calculator to insert data into your table, here some info and code samples about how to insert records into your db:

https://docs.joomla.org/J4.x:Inserting_Updating_and_Removing_data_using_JDatabase

you can use this code within the php section without problems.

Hope this will do the work

Best regards
Silvia Martín
Moonsoft Team

...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!