CalcBuilder Forum

I have some doubts

Usuario thiagobarreto 2020-05-22 22:05:29

Hello
I have some doubts with my calculators.

1ª: how do I align the text inside the fields box?
2ª: how to change the size of the fields box within a table?
3ª: how to use the if function with reference to an option list item?
4ª: how to create a condition to disable (disable the selection) an item in the option list?

Edited by thiagobarreto - 22.05.2020 23:36

Moonsoft support 2020-05-24 09:25:39

Hello,
your questions 1 and 2 are related to the final styles that are used at your page, so the proper way to adjust will depend on the classes and styles provided by your template, and the version of bootstrap you're aplying (if any). If you want to apply any custom class toa field you can add it at the css class parameter you will find at each field configuration page. We can visit your page and point out which are the styles you could adjust, please place a private ticket at the helpdesk where you can privately share your url and we'll take a look.

Regarding question 3, at the calculation time, the option list field will be returned same way the other types, with the name of the field, you if you called it 'myoptionlist' you will have
$myoptionlist
containing the value selected available at the calculation step. So you can use if statements or any other normally

if($myoptionlist=="value1"){
...
}

And finally, there is one special option list type that allows disabling options depending on the value of another option list, it's the linked list type. You can check the configuration needed at page 15 of the quick guide you can download here:

https://www.moonsoft.es/easyblog/entry/8-calcbuider-quick-guide

If you will need any other more complex way to disable the options, depending on a combination of user intputs from several fields, for ex, you will need to build this behavior using javascript section, please note you can also ask for custom code if you're not familiar with js.


Hope this helps, regards
Moonsoft Team

Usuario thiagobarreto 2020-05-25 17:36:04

Hello
I managed to solve question number 3, the double "" == "" was missing. Thank you so much for this!

the calculator link is this:
http://neoped.net/neonatologia/calculadoras/9-calculadoras-em-neonatologia/5-hidratacao-venosa-em-neonatologia

Usuario thiagobarreto 2020-05-25 23:10:12

I tried to do what is described on page 15 of the manual, but I believe that is not exactly what I need.

what I need is the following

http://neoped.net/neonatologia/9-calculadoras-em-neonatologia/5-hidratacao-venosa-em-neonatologia

In this first list of options "glicose", I need that depending on a (calculated) value, some of these options are not available for selection. example (SG5%, SG10%, SG25%, SG50%).

Moonsoft support 2020-05-26 08:14:05

Hi,
ok, for your questions regarding style:
you can add any custom style directly to your calculator as your template doesn't seem to have any specific class for handling this. So, at the required fields you want to align right, for ex, you can add

mystyle

at the parameter css class. And then you can add this style to the javascript tab
javascript events->write directly at the html page, please add a tag style there and insert the class with needed properties


//open style tag
.mysyle{
text-align:right;
}
//close style tag

About the size of the fields, we see you have already applied input-small, you have also input-large available and the rest of the sizes as well. Does this solve your question?

If we understood properly, you need to calculate one value depending on the some input values, and then modify dynamically the options of the combobox. This is not an option you can set directly at the configuration, you would need to add some javascript code in order to achieve that. You would need to configure that output field as an 'inline result' so it refreshes and calculates with the other fields, and then capture that result and modify your combobox. You will need at least an average knowledge of js in order to build this, please note you can also ask for a custom script, if you prefer us to do the custom function, please place a ticket at the helpdesk system explaining the conditions you'd like to add.

Best regards
Moonsoft Team

Usuario thiagobarreto 2020-05-28 19:33:55

I managed to solve a question 2 and 3. Thank you very much!

on question 1. I tried to do what you suggested. creating a style to align the text.
but the code is written on the site itself:

// open style tag
.mystyle {
text-align: right;
}
// close style tag

and it didn't work.

about the other problem I'm interested in a js code. I'll send you a message

Usuario thiagobarreto 2020-05-28 19:40:52

I was thinking. maybe if the option selected in the list of options was not compatible,
is there a way to create an error message by clicking the "calculate" button?
would solve my problem

Moonsoft support 2020-05-29 08:31:36

Hi,
ok, when we write //open style tag or //close style tag it means you need to write an html tag style there, we can't insert this tag at the forum text as it's not intended to show code. If you open and close a style tag you shouldn't see the code at your page and the style being applied instead, as shown here (remember to open and close the tag properly):

https://www.w3schools.com/tags/tag_style.asp

Hope this helps, regards
Moonsoft Team

Moonsoft support 2020-05-29 09:07:57

Hi,
yes, you have a section at the javascript tabs, the one titled 'executed before calculate execution' will run when you click calculate button. You can add custom validations there and cancel the calculator launch if needed. If you write there for ex:

alert("validation");
return false;

you will force to show an alert and cancel the calculation with the return false line. You can add any valid javascript code at this section.

Also following the javascript approach, you can create custom validators for your fields, you can find a tutorial with some example code here:

https://www.moonsoft.es/easyblog/entry/23-code-tip-add-custom-validation-to-form-fields

Hope this helps, regards

...
List Manager

Build different lists for your site

Buy now!
...
Support/development

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

Buy now!