Survey multi-page form with hiddens score fields

Hi,
I have to create a survey form, and I’m having some trouble on how to begin and the logic to set.

It’s a survey that gives you 3 recommendations of perfumes depending on your answers.
There are 15 perfumes, 10 questions and for each proposition there is a list of perfumes.

Ex. Q1: What kind of perfume do you like?
A1: feminine → 10 perfumes
A2: Mixte → 5 perfumes
A3: No opinon

Ex. Q2: What scents do you like?
A1: flower → 5 perfumes
A2: fresh → 5 perfumes
A3: yummy → 5 perfumes

At the end, each perfume has a total points and I have to select the top 3 as result.

How do you think I should approach this?
Thanks,
Jennifer

Hi Jennifer. The team tried to come up with an approach to this, but could not come up with anything simple. None of the solutions we came up with can be accomplished without custom programming.

If you are OK with the customer programming, here is the simplest approach we came up with.

You could have a multi-dimensional array of possible perfumes for each radio button choice. For example, the first array would be for radio button field 1, with the multiple dimensions being like this:

$radio_1 = array (
			"1" => array ( "Noir", "Chanel", "Drakkar" ),
			"2" => array ( "Chanel", "Balenciaga", "Rose", "Black", "Flower" ),
			"3" => array ( "Parfum", "Chanel" )
		);

That would allow you to loop through all the radio button fields in the form, check which option was submitted (1, 2, or 3), and with that increment a counted as a ‘vote’ for the matching perfume. In the end, you will have fifteen ‘perfume’ variable counters, each with the number of ‘votes’ based on a matching radio button selection.

At that point, you would need some additional PHP to determine the top three perfumes and what you do in the event of ties and display that on the next page of the form or the form confirmation page.

That is one way to approach it. If you have any other questions, please let us know.

Hi Chris,

That’s exactly what I was thinking.
Since I wasn’t so sure about the PHP part, I ended up doing it in Javascript

  1. Each radio as a value
  2. When the form is submitted, I add the values as params in the URL (query string)
  3. In my confirmation page, I match the values of my URL with a JS object and do some calculations
  4. I display the top 3.

I’m still working on the ties.

Thanks again!

You’re welcome. JavaScript also works; you can have the information before the form is submitted! Share what you build when it’s ready. Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.