[Pro] Online Survey form

I’m using the easiform actions to create an online survey. As part of this there will be a series of radio buttons to allow the user to give a graded response to specific questions.
Its early days with this, I have used the easiform actions to create a contact page but this is a bit different.
Currently I am unsure how to get the radio buttons to retain the selected state in one response, as moving onto the next line the radio button state changes thus in the whole page only one radio button can retain the selected state.
How can each question on the page retain its selected radio button state?
What am I missing here?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Each group of buttons needs a unique name. So all the buttons for question one would have the name question_one, all the buttons for question two would be question_two, etc.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Aha! Couldnae see my nose for my face there! I’ll get back to it and see if I can get it to work.

Only 8 hours left on the Kickstarter fund.
Hope your not feeling despondent. If I had the money I’d pitch in with more.
Best of luck and many thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Moving on with things…
I hadn’t planned it this way but he questionnaire will have to run over a few pages. How can the results from the previous pages be compiled as people move through the pages and not be lost as they move onto the next pages?
I can’t quite work this one out.
Any help welcome.

The countdown continues…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You have two or three choices here.

Best way: Save them to the server, and maintain a cookie or another token (maybe in the URL) to carry along the user id so you can keep the answers together.

Next way: Save them in the cookie as a hash or similar structure. You have seriously limited space in the cookie, so depending on your survey size, this may not be acceptable.

Last way: Hidden form fields. Post (or get) from page 1 to page 2 (make it the Action of the form on page 1). In the Form Setup on page 2, set up one hidden form field for each of the fields on page 1. Make them like this:

  • Name: the_field_name_as_it_is_on_page_1
  • Value: <?= $_REQUEST['the_field_name_as_it_is_on_page_1']?>

If you do it this way, then you don’t want to post to your EasyForm handler until the last page in the process. That last page will be a doozy – with more hidden fields than visible ones – but the whole thing will post to the server in one shot.

The reason why this is the last way is because you don’t get anything at all unless the visitor makes it all the way through. The reason why saving it on the server and issuing a token is the best way is because you do get incremental data, even if people drop out before the end.

Walter

On May 31, 2012, at 2:35 PM, tonzodehoo wrote:

Moving on with things…
I hadn’t planned it this way but he questionnaire will have to run over a few pages. How can the results from the previous pages be compiled as people move through the pages and not be lost as they move onto the next pages?
I can’t quite work this one out.
Any help welcome.

The countdown continues…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walter provided an example using cookie.js which did this with a shopping cart and i am sure it could be used with your survey.

Have a look here for the example I created and there is a link on that page to the FWT thread. http://deltadesign.co/fw_examples/walts_scripts/index.html

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walter and also Dave for your input.
How would I go about the Best Way you mention Walter?
I had a look at the example you linked to Dave but itmay be too much for me to contend with. The menu is very neat and as you mention one to be filed as very useful but I reckon I’d end up getting too digressed from what I’m hoping to achieve.
If you had the chance to outline the Best way then I’d maybe give that a go.

All the best for now.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I don’t know how EasyForm works on the server side, so this is supposition. But basically you would create a form handler for page 1 that would redirect to page 2 after a successful submission, and pass along a token identifying the user. This could be almost anything, you just want it to be random and unique.

Here’s a rough (and untested) example, using MyActiveRecord code in PHP.

What this does is take a form post, assign all of the fields that are not named beginning with an underscore to the survey object, then save that object. Then it redirects to the next page, including the token in the querystring of the URL. In your survey-page-2 Form Setup, you would create a single hidden form element to capture this token:

  • Name: token
  • Value: <?=$_REQUEST['token']?>

Now just carry on with all the second page fields, post to the next handler (which can be a copy and paste of the first, except for the URL of the next field) and so on. On the last handler, redirect to your Thanks For Participating page, and give them the raffle ticket or toaster or whatever you promised.

If you wanted to avoid all the duplication, you could simply include another hidden field in your form, and modify the handler to expect it. Something like this:

  • Name: _next_page
  • Value: survey-page-3.html

Then your handler would redirect to that page, using something like this:

$next = 'http://example.com/' . $_POST['_next_page'];
header('Location: ' . $next);

So you could get away with one handler for as many pages as you like.

Walter

On May 31, 2012, at 3:10 PM, tonzodehoo wrote:

Thanks Walter and also Dave for your input.
How would I go about the Best Way you mention Walter?
I had a look at the example you linked to Dave but itmay be too much for me to contend with. The menu is very neat and as you mention one to be filed as very useful but I reckon I’d end up getting too digressed from what I’m hoping to achieve.
If you had the chance to outline the Best way then I’d maybe give that a go.

All the best for now.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Basically easiForm creates an array called ‘f’ and then sets an array ‘key’ by the name of the Name that is given to the form element in the inspector that has the easiForm Element action applied to it, so if a field on a form has the easiForm Element action applied to it and the field is given a Name of ‘your_name’ then easiForm will convert this to f[‘your_name’] and give it the value that the form user enters to that field so if the user enters ‘Mike Smith’ in the ‘your_name’ field the value of the key from the array named f will be Mike Smith
Any form element without the easiForm action applied to it will be ignored.

Let us say you have your form split over 3 pages with a final page to let the user know the form was sent, these pages could be called say: page1.php, page2.php, page3.php and success.html

success.html

  1. Create a page named success.html and put whatever text you need there.
  2. Move on to the next stage…

page1.php

  1. Add the form elements to this page
  2. Add the easiForm Elements action to each of those elements
  3. Do not add the easiForm Elements action to the Submit button
  4. Do not add the easiForm action to this page
  5. Open ‘Form Setup’ under the ‘Page’ menu
  6. Set form ‘Method’ to POST and the form ‘Action’ to page2.php
  7. Close the form set up windows and move to the third stage…

page2.php

  1. Add the form elements to this page
  2. Add the easiForm Elements action to each of those elements
  3. Do not add the easiForm Elements action to the Submit button
  4. Do not add the easiForm action to this page
  5. Open ‘Form Setup’ under the ‘Page’ menu
  6. Set form ‘Method’ to POST and the form ‘Action’ to page3.php
  7. Add a Markup item to the page anywhere above the first form element and add the following code:
<?php
if (!isset($f)) { 
    $f  = (isset($_POST['f'])) ? $_POST['f'] : '';
}  
foreach ($f as $key => $value) {
    echo '<input type=hidden name="f[' . $key . ']" value="' . $value . '">';
}   
?>
  1. Close the form set up windows and move to the fourth stage…

page3.php

  1. Add the form elements to the page
  2. Add the easiForm Elements action to each of those elements
  3. Add the easiForm Elements action to the Submit button
  4. Add the easiForm action to this page and set it up, select success.html as the Success page.
  5. Add a Markup item to the page anywhere above the first form element and add the following code:
<?php
if (!isset($f)) { 
    $f  = (isset($_POST['f'])) ? $_POST['f'] : '';
}  
foreach ($f as $key => $value) {
    echo '<input type=hidden name="f[' . $key . ']" value="' . $value . '">';
}   
?>
  1. Close the form set up windows and upload to the server, you should be ready to go and the 3 stage form should work as you expect it to.

HTH

On May 31, 2012, at 9:34 PM, Walter Lee Davis wrote:

I don’t know how EasyForm works on the server side, so this is supposition. But basically you would create a form handler for page 1 that would redirect to page 2 after a successful submission, and pass along a token identifying the user. This could be almost anything, you just want it to be random and unique.

Here’s a rough (and untested) example, using MyActiveRecord code in PHP.

gist:2845624 · GitHub

What this does is take a form post, assign all of the fields that are not named beginning with an underscore to the survey object, then save that object. Then it redirects to the next page, including the token in the querystring of the URL. In your survey-page-2 Form Setup, you would create a single hidden form element to capture this token:

  • Name: token
  • Value: <?=$_REQUEST['token']?>

Now just carry on with all the second page fields, post to the next handler (which can be a copy and paste of the first, except for the URL of the next field) and so on. On the last handler, redirect to your Thanks For Participating page, and give them the raffle ticket or toaster or whatever you promised.

If you wanted to avoid all the duplication, you could simply include another hidden field in your form, and modify the handler to expect it. Something like this:

  • Name: _next_page
  • Value: survey-page-3.html

Then your handler would redirect to that page, using something like this:

$next = ‘http://example.com/’ . $_POST[‘_next_page’];
header('Location: ’ . $next);

So you could get away with one handler for as many pages as you like.

Walter

On May 31, 2012, at 3:10 PM, tonzodehoo wrote:

Thanks Walter and also Dave for your input.
How would I go about the Best Way you mention Walter?
I had a look at the example you linked to Dave but itmay be too much for me to contend with. The menu is very neat and as you mention one to be filed as very useful but I reckon I’d end up getting too digressed from what I’m hoping to achieve.
If you had the chance to outline the Best way then I’d maybe give that a go.

All the best for now.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Ok, I will try to be as coherent as possible in trying to get to grips with this as I’m not 100% conversant with all that you mention so forgive me if I appear to not explain myself very well.
So to get this going firstly where would I put the code you have there?

Would it be possible to use the ‘next page’ button as the form element to capture this token?

I look forward to learning a lot from this process as its something I am looking to use for a few clients.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Do try Mike’s approach, since you’re already set up with EasiForm. What he’s outlined in his message is a variation on the “hidden fields” approach, which means that the form will only be saved to the database on the last page of the survey.

On May 31, 2012, at 5:16 PM, tonzodehoo wrote:

Ok, I will try to be as coherent as possible in trying to get to grips with this as I’m not 100% conversant with all that you mention so forgive me if I appear to not explain myself very well.
So to get this going firstly where would I put the code you have there?

This is not a complete example, you would need a few more parts. MyActiveRecord is at GitHub - walterdavis/myactiverecord: Fork of MyActiveRecord by Jake Grimley

I’ll see if I can put a complete example together for you later.

Would it be possible to use the ‘next page’ button as the form element to capture this token?

No, the next page button needs to be a form submit button, because you’re submitting the form to the server for processing. I would leave the token in the form (on page 2 - n) as a hidden field. You’ll still be passing the token in the querystring as well – that’s by design.

Walter

I look forward to learning a lot from this process as its something I am looking to use for a few clients.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On May 31, 2012, at 11:16 PM, tonzodehoo wrote:

Ok, I will try to be as coherent as possible in trying to get to grips with this as I’m not 100% conversant with all that you mention so forgive me if I appear to not explain myself very well.
So to get this going firstly where would I put the code you have there?

  1. *** Add a Markup item *** to the page anywhere above the first form element and add the following…

This can be found under the ‘Insert’ menu.

Would it be possible to use the ‘next page’ button as the form element to capture this token?

Yes, sorry I was just thinking Submit but you can call the button as you like.

I look forward to learning a lot from this process as its something I am looking to use for a few clients.

If you needed to add any more pages to the process then they would be created as outlined under the stage for page2.php

I will send you a small 3 page example in about 15 minutes.

HTH


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Here’s a three-stage form, ending on a Thanks page that lists all of the answers from all three stages:

http://scripty.walterdavisstudio.com/multi

You can download the Freeway document and the site folder (compressed together) here:

http://scripty.walterdavisstudio.com/multi/multi.zip

The MySQL server configuration has to be set in the config.inc.php file in the site folder, and the handler.php is also hard-coded for my server (the redirect path includes the server name) so you have to change that as well. Freeway won’t upload these files (or the lib folder) so you need to do that manually.

Use phpMyAdmin or another database access tool to set up a database table that looks like this:

id [int(11), primary key, auto-incrementing]
one [varchar(255)]
two [varchar(255)]
three [varchar(255)]
four [varchar(255)]
five [varchar(255)]
six [varchar(255)]
seven [varchar(255)]
eight [varchar(255)]
nine [varchar(255)]
token [varchar(255), index]

Set it to have defaults of UTF-8 and unicode-general-ci charset.

There are hidden fields on the Page / Form Setup in Freeway, and the Thanks page has a Page / HTML Markup in the Before HTML slot where the values are read back in. All of the forms submit to handler.php. (I’m using the _next_page hidden form field to pass the user along.)

Walter

On May 31, 2012, at 5:16 PM, tonzodehoo wrote:

I look forward to learning a lot from this process as its something I am looking to use for a few clients.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’m back onto this after a bit of a delay.

I’ve set up the form as you can see here:
http://www.brettnichollsassociates.co.uk/acesprojecteval.php

I followed the instructions as given by Mike but am getting a warning:
Warning: Invalid argument supplied for foreach() in /homepages/30/d309824077/htdocs/wsb5645101801/acesinterimevalu2.php on line 261

I suspect that this may be a bit to do with the route of the instruction in that the link is not being made.
If you managed to have the chance to have a look at this and let me know where I may have gone wrong.

Its safe to try to complete the survey as any email outputs are set to come to me rather than the client.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I think the best thing to do is send the Freeway file to me by email, I am really pushed at the moment so this would be the quickest way for me to find out what is wrong as I can then see all the code you have entered, where and how.

Very important for your forms: I suggest you do is give your radio cluster understandable names and values, your first page reads:
Cluster1 with values of Item7, Item8 etc.
Cluster2 etc. same etc.
Cluster3 etc. same etc.

When you get to the satage of receiving a reply this will make absolutley no sense to the person that it goes to unless you change the cluster ‘Name:’ s and ‘Values:’ s

For example, the first page…

‘Cluster1’ radio buttons could be renamed as ‘roles_described’ with each radio button in the group having a value of ‘1’ through to ‘5’

‘Cluster2’ radio buttons could be named as ‘detailed_com’ with each radio button in the group having a value of ‘1’ through to ‘5’

‘Cluster3’ etc. etc. then through each of all the other pages and radio clusters.

On Jul 18, 2012, at 8:15 PM, tonzodehoo wrote:

I’m back onto this after a bit of a delay.

I’ve set up the form as you can see here:
http://www.brettnichollsassociates.co.uk/acesprojecteval.php

I followed the instructions as given by Mike but am getting a warning:
Warning: Invalid argument supplied for foreach() in /homepages/30/d309824077/htdocs/wsb5645101801/acesinterimevalu2.php on line 261

I suspect that this may be a bit to do with the route of the instruction in that the link is not being made.
If you managed to have the chance to have a look at this and let me know where I may have gone wrong.

Its safe to try to complete the survey as any email outputs are set to come to me rather than the client.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hello Mike,

Cheers. I’ve emailed it through to you. Let me know how you get on.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You had me pulling my hair out on this one for a while… Basically the forms did not work and the error was thrown because the file you sent me through did not have a Submit button, you had the image but the ‘Submit’ option was not selected… so how did the form get sent to the next page? you had the ‘Next page’ image set with a link to the next page!!! Well, you had me calling myself some names after that, I just could not work out how the array was not being passed when the $POST was set and the form appeared to be going to the page it was supposed to go to… %^%+***!

The error was thrown because no array existed, your form was being directed to the next page on pressing a ‘linked image’ and not on ‘Submit’ the array was not actually getting sent… so it didn’t exist, I have altered a little bit of the code to check that there is an array passed although once set up as they should be this should not be necessary although it does not need to be there, the code to change is as follows:

<?php
if (!isset($f)) { $f = (isset($_POST['f'])) ? $_POST['f'] : ''; }

foreach ($f as $key=> $value) {
    echo '<input type=hidden name="f[' . $key . ']" value="' . $value . '">';
}
?>

to

<?php
if (!isset($f)) { $f = (isset($_POST['f'])) ? $_POST['f'] : ''; }

if (is_array($f)) { // Stop errors when empty.
foreach ($f as $key=> $value) {
    echo '<input type=hidden name="f[' . $key . ']" value="' . $value . '">';
}
}
?>

Now on to the main problems:

  1. You form is on various layers, you should place everything that is form related 'including the submit button or image on one layer, the easiest way to do this is to build the whole form within a table, the whole thing in ‘one’ table. Use the different cells to place the markup item with the php code, the form text, your radio buttons and the submit button. The text doesn’t * need * to be there but if it is then the text and related radio buttons will sit on the page related to each other.

  2. If you use an image for a submit button then it needs to work as a ‘Submit’ button. Giving an image a hyperlink does not make it a submit button, it makes it a link, so…
    Remove the hyperlink from ‘Next Page’ images on each page, then when the ‘Next Page’ image is selected you should check the box for ‘Submit’ in the inspector, this will then make the image submit the form.

  3. On the ‘Interm Evaluation’ page you ‘I think’ are trying to use text areas for user input for the ‘Please feel free…’ sections, you have the easiForm Elements action applied to two items, I have not a clue what these originally where ‘I suspect HTML items’ but they are selected as .gifs, which is not any use at all as these items cannot be used as text areas, you should replace these two items with actual ‘text areas’.

Nothing to do with the forms function but…

  1. You have not given any ‘Name’ or ‘Value’ to any of the radio buttons in each cluster, you have just let Freeway set automatic values, so when you form comes through you will get:

Cluster1: item3
Cluster2: Item7
Cluster3: Item11
etc. etc.

What you should do is give all of the radio button in each cluster the same name, a name that related to that radio button selection, on the first page that could be:

Cluster1 name: ‘roles_described’ with each radio button having a value from 1 through to 5 relatively.
Cluster2 name: ‘plan_communication’ with each radio button having a value from 1 through to 5 relatively.
etc. etc.

This will then result in the information coming back in the email as:

Roles described: 2
Plan communication: 5
etc. etc.

Please note that anything that has the ‘PHP easiForm Element’ action applied to it cannot have a space in it’s ‘Name’ although the ‘Value’ could if that where ever needed. If you want a space to show in the message that is returned then use an under slash as the example above does, the first char of the ‘Name’ will be converted to an uppercase letter as the above example also shows.

  1. You have added the ‘Form Element Styler’ action to every radio button, you are not using this to do anything so there is no real point in it being there, this does not affect the function of the form but it sets a style for every radio button it is applied to without any need to.

  2. Every bit of text on your pages are selected to be .gifs! Not sure why you are doing that but it would be better to use ordinary html text, that is what I would do rather than covert all the text to images and stop the second of alt text showing before the text images load, this will also reduce the size of your pages.

I guess that is a lot to sort out but you really don’t have a lot of options if you want to get this working, keep us up to date as to your progress.

HTH

On Jul 18, 2012, at 10:4 PM, tonzodehoo wrote:

Hello Mike,

Cheers. I’ve emailed it through to you. Let me know how you get on.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Wow! Bit of a pigs ear really!
I did have it all set up in tables intially but the spacing and styling were drivin me a bit nuts so I went back to doing it as blocks of text so that I could at least get it looking the way I wanted it to look, which was important for the client to see.
I knew the functioning of the buttons etc wasn’t right but my attempts at resolving it were taking me round in circles.

There is a lot for me to get on with and I really trully appreciate you taking the time and expending so much of your frustration and energy on this. I’m sorry for giving you a headache wae it!

I am off on holiday for a week so may leave this till I get back so excuse me for the break. Maybe you might need a break also after what I have put you through!
I reckon I shall come back to it fresh after a break.

I’ll try to be a bit better prepared if I encounter any further issues. I guess all I need to know is that what I am wanting to achieve is achievable using the easiforms set up and the added bits of code you have set up.

All the best for now. Many many thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You can control things reasonably well with a table, in fact in many ways you have better control as a table tends to hold the layout together very well, just remember you ned to put all the form elements in that table so the php code markup and the submit button should also be part of it.

You could use the image you have in the background as a ‘background’ image, that would also get rid of one of the layers and make the pages a little less cumbersome to work with.

It is all very doable and straightforward as long as you follow the principals of a table structure.

HTH

On Jul 19, 2012, at 11:9 PM, tonzodehoo wrote:

Wow! Bit of a pigs ear really!
I did have it all set up in tables intially but the spacing and styling were drivin me a bit nuts so I went back to doing it as blocks of text so that I could at least get it looking the way I wanted it to look, which was important for the client to see.
I knew the functioning of the buttons etc wasn’t right but my attempts at resolving it were taking me round in circles.

There is a lot for me to get on with and I really trully appreciate you taking the time and expending so much of your frustration and energy on this. I’m sorry for giving you a headache wae it!

I am off on holiday for a week so may leave this till I get back so excuse me for the break. Maybe you might need a break also after what I have put you through!
I reckon I shall come back to it fresh after a break.

I’ll try to be a bit better prepared if I encounter any further issues. I guess all I need to know is that what I am wanting to achieve is achievable using the easiforms set up and the added bits of code you have set up.

All the best for now. Many many thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options