CalcBuilder Forum

Prequalify for 2 separate calculators

User moon_584 2012-07-07 23:22:09

I have two calculators built and I'm trying to figure out a way to have a set of pre-qualifying questions, and depending upon the answers, would send the user to one calculator or the other. Do you have any ideas on how I can do that?

Moonsoft support 2012-07-09 17:46:42

Hello,
you could build that structure in some different ways, depending on your coding level you could do:

Place each calculator inside a different article, and create a new article with a third calculator containing the questions. The solution to be shown for this calculator is the link to follow to the corresponding calculator.

Or

Place the three calculators inside the same page, placing your two calculators inside hidden divs. The question calculator could hide/show each of the divs depending on the answers using javascript events section.

Hope this helps

User moon_584 2012-07-10 22:22:00

The first option did the trick. I'd really like for them to be able to go directly into the new article without having to click a link. It sounds like the second option would make that happen? Still a rookie, not sure how the javascripts work.

Moonsoft support 2012-07-11 09:15:25

Hello,
yes, the second option uses a different approach, we see it as a single article with sections showing/hiding dynamically. This would avoid using links to show the calculators, but it would require some more complex coding indeed. The javascript section starts execution when the page is ready, so you should add new events to the elements needed at the questions form in order to hide/show the calculators below, that you should have placed inside a block (each one inside it's own div, for example), in order to change the display of the block when required:
display (none/block)

You will find an example at download section called

Hide/Show form fields depending on select combo box

that could show you how the code should look like, hope this helps.
If you want us to code this first calculator for you, please note you can also book the custom calculator service.

User moon_584 2012-07-22 17:54:42

I ended up using the first option and it works fine for what I need. Now I want to take the field entries from one calculator and pre-fill them into corresponding fields in the next calculator. Is this possible? Any suggestions?

Moonsoft support 2012-07-23 10:59:51

Hello,

By now, there´s a way you can get fields from other calculator without changing code in PHP source. We could use cookies.

In first calculator add cookies at 'fields and code' in code section like this:

setcookie('NAME_TO_GET_IN_NEXT_CALC', $FIELD);

This makes the calculator set the cookies when user press 'Calculate' button.

In second calculator we need to get the cookie value. If you use Joomla 1.6+ you can do it with mootools. Just type in Javascript events something like this :

getCBFormValue('ID_OF_THE_FIELD').set('value',Cookie.read('NAME_TO_GET_IN_NEXT_CALC'));

This example is for an input type text. Maybe you should change javascript event in second calculator to set values to textareas, select, multiple input,...

Hope this helps. Regards,

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
Support/development

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

Buy now!