CalcBuilder Forum

Generate different output based on dependent variables

User TheFencepedia 2024-09-11 20:41:00

Hi there,

We've been building a site that generates fence drawings based on a form input. However, we want to potentially have the system set up so that it will generate a different drawing based on the variables selected in the frontend.

So essentially, we'd have a field on the front end where the user can generate something, which then triggers another field that automatically changes the drawing based on the input in the selected field. If that makes any sense.

Can we do that? Is there some more information about dependent fields that we can look at somewhere? I've attached a video, to explain a little more.

Moonsoft support 2024-09-12 12:42:35

Hi,
the dependant fields can be configured in a way you have for example 2 comboboxes, one for car 'brand' and the other for car 'model'. You want user to choose the brand, and the second combobox model should show only related values (models of selected brand). So you would configure the main list 'brand' as a default combobox, filling all values, and the model as a 'dependant field' with a query to database where the filter would be the selected value for brand. You would configure the trigger field 'brand'. This way each time user changes the value for 'brand', the second combobox will reload itself recovering proper values.

According to your image use case, where you don't need an input field to be filtered, but a different output to change, we would suggest another approach instead using inline output, this way:

Create a new field, for ex
imageoutput

with type= Others-> Inline

And place it at your form layout as any other input field
##imageoutput##

Now look for the input fields of your form that you want to reload this image. Check for them the option 'Preferences'->Reload Inline events

This means each time user changes that field, the imageoutput (and the rest of the inline fields you may add) will 'recalculate' and show a different content.

Finally, at your code section, you need to set the value of the imageouput, you can use any of the input fields to calculate the content to show. For ex:

<img src="https://www.moonsoft.es/assets/images/tickets/t4680_1.png">

...or any other calculation you may need to build the right output.

Hope this helps, best regards

Silvia Martín
Moonsoft Team




User TheFencepedia 2024-09-18 01:33:18

Thanks. I've hired someone to create the code portion for me.

How would I go about applying a size to the image? Since they will be different images based on the above process, I can't format the size the way I usually would.
Would I just use the output variable in my exit layout and then apply HTML formatting to that? If not, what would you recommend? Also, some of the drawings might be different sizes etc. Is there any way to set one parameter as fixed and the others as auto?
Sorry! Just trying to figure out how to integrate the PHP code with the HTML output.

Moonsoft support 2024-09-18 09:16:11

Hi,
yes, any of those solutions would be valid. As you are generating the image tag, you can set there dynamic height and weight at the same time you generate dynamic url, and/or different style classes that can give it a different look . You only need to take into account any content you set at the 'imageoutput' variable, it will be 'pasted' into the html as is, so if you generate the image tag with any property, for ex

height="250" width="300" class="yourcustomclass" src="....."

you will see at the html output that same tag with all properties, it's handled as any other text so it will print exactly what you generate.

Please note we have a custom calculator service, for providing any section of code or even the whole calculator, feel free to ask for a quote in case you need further help with the coding section.

Best regards

Silvia Martín
Moonsoft Team

User TheFencepedia 2024-09-18 17:04:36

Thanks, but your rates are super high.

I've hired someone more affordable.

Moonsoft support 2024-09-19 09:13:49

Hi,
on the contrary, according to the general feedback they are far below of what the quality of the service would deserve :) . But we understand in an environment of worldwide customers this perception also depends on country and other factors.
And anyway, that's perfect, in that case you won't have any problem to build the desired output because the code needed is quite simple and in addition we've already provided the example, so it's just a copy&paste problem now.

We close this ticket then, you can open a new one in case you have any other question about the configuration.

Best regards
Silvia Martín
Moonsoft Team

...
List Manager

Build different lists for 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!