This topic is locked

Multiple screen add page

11/11/2008 8:23:26 AM
PHPRunner General questions
T
thesofa author

Hi

I am sure we have all filled in online questionaires, I have noticed a change in style recently where instead of having a vast list of questions on one page, the questionaire is set up to have 3 or 4 questions on a screen, with a progress bar along the top of the screen and a 'Next@ button at the bottom, I assume that the next button saves the screen data each time it is clicked.

Has anyone got a solution firstly for splitting up a long list of questions into multiple pages linked with the next button saving the data as it goes?

also has anyone managed to build a decent progress bar, so those filling in the questionaire have a gauge of how much more they have to do?

TIA

George

R
randall 11/11/2008

I never got multiple pages to work, but I did simulate multiple pages with javascript. Specifically, I used Adobe Spry v1.6.1 (which is FREE) Tabbed Panels to achieve the effect. Basically, I replaced the main part of the ourdata_add.htm with the Tabbed Panel divs. Tabbed Panels probably aren't the right solution for you but hiding data via javascript is the way to go.

O
OLDmrcaseyman 11/11/2008

Hi

I am sure we have all filled in online questionaires, I have noticed a change in style recently where instead of having a vast list of questions on one page, the questionaire is set up to have 3 or 4 questions on a screen, with a progress bar along the top of the screen and a 'Next@ button at the bottom, I assume that the next button saves the screen data each time it is clicked.

Has anyone got a solution firstly for splitting up a long list of questions into multiple pages linked with the next button saving the data as it goes?

also has anyone managed to build a decent progress bar, so those filling in the questionaire have a gauge of how much more they have to do?

TIA

George


Could you make several views? Have a view for each page, use events each time to redirect to the next view.

That status bar at the top could be a static image that would represent that stage of progress through the pages.

Instead of "Save" the button could be changed to "next".

D
drh 12/4/2008

Hello forum.

I too am interested in creating a questionaire type app with multiple pages. In addition to splitting the questions up into multiple pages, I would like to display different questions based on the answer to questions on the prior page. I would start with something simple. Page 1 may have only 1 question, with a choice of 3 answers (a, b, or c). Page 2 would have different questions based on whether the choice on page 1 was a, b, or c.
All pages would have a Next and Back button on them. The final page would have a submit button, which would write the record to the database, with all the user supplied data (answers to questions).
Did you get this to work sofa? If so, did you use one of the suggested solutions, or did you come up with something else? Would you be so kind as to share your solution.
I am looking for the best way to accomplish this project without having to reinvent the wheel.
I will be using PHPRunner 5 and mysql database.
Thanks for any pointers or suggestions in advance.
Dave

S
swanside 12/4/2008

I did it in a way for a job sheet we have in work, there are five sections on it, WOrk details, Gas Details, Electric details, Risk Assessment and Work Carried out.
What I did was make five tables, as named above, then in each table I have a Job_No which is relevent to them all, once one section is completed it wil show a link for the next section.
I have made a quick demo here
http://demo.asprunner.net/pggrimes%5Fhotma.../first_list.php
Nothing special, but may start you in another direction.

D
drh 12/4/2008

Thanks for the reply swanside. I took a look at the demo link you provided. I need to look a little closer probably. It is not exactly what I am looking for, but it does give me another road to go down. I currently am trying to use the multiple view solution, but progress is slow at best.
I continue to work and learn. If not for this project, maybe for a future project.
Thanks again for your reply.
Dave

S
swanside 12/5/2008

What I tried to do was on the save of the first page, I wanted it to take me to the Add New for the next page and so on, so it would not keep going back to the list, but I couldnt get it to do that.

S
steveh 12/5/2008

I've done a similar thing, I show and hide the menu options so they see the correct choices.
When they click start here I insert the record (all fields on the DB are allowed to accept nulls), then I've created a number of views for each page, the after update of 1 takes them to the edit of the next etc.

T
thesofa author 12/5/2008

OK, this is what I wanted and how it works

School wants to find the answers to various questions abourt teaching styles, so first I have to get the student logged in.

Most of them cannot spell their names correctly so I have made the name field from the login screen into a dropdown list, sorted alphabetically so they type the first letter of the login name and it seeks the first entry of that letter, they then scroll down to the right login name

they then enter their network passsword and the page authenticates with AD via LDAP.

Now I get the school year they are in, and I use that year as a "where" filter in the Subject dropdown list, so kids can only see the subjects taught to that year group. Then they have to chose the subject for the survey from the dependant dropdown list that only shows those teachers who teach the chosen subject to that year group.

They then click the renamed Save button, labelled Next.

This saves the record, and an after event sends it to the next page, where i only use the edit page , based on the next custom view of the dataset.each time the page is saved, again through the "Next" button, the following edit page for the next View is called, so all the details are saved as we go along.

They cannot go back, and all fields are compulsary so they cannot go forward without answering.

Last page is a heavily hacked View page that logs them out and returns to the login page.

It works
BUT

if you want to have different pages of questions for different choices

You said

What I tried to do was on the save of the first page, I wanted it to take me to the Add New for the next page and so on, so it would not keep going back to the list, but I couldnt get it to do that.



If you try to redirect from a list page after using Inline Add or Inline Edit, it will not work, so assuming you have used the Add page to set up a new record you can use the code here

//get id of last saved survey and make a session variable

$id = mysql_insert_id();

$_SESSION["id"]=$id;



This gets the saved ID of the record into a session variable.

so if your first page has a choice of 3 questions, why not use the save button as a next button and the record gets saved, then have a

If ($choice==a){

//********** Redirect to another page ************

header("Location: v_ans_6_add.php);

exit();

}

If ($choice==b){

//********** Redirect to another page ************

header("Location: v_ans_5_add.php);

exit();

}

If($choice==c){

//********** Redirect to another page ************

header("Location: v_ans_4_add.php);

exit();

}



section to determine where you are going?

As you add each record, use the $_SESSION["id"] as the value for the link to the main table, added as an after record saved event.
Or you can have all the different answers held in one table and just use my different custom views method with edit pages for the main table.
HTH

D
drh 12/5/2008

Thanks for all your replies. Frankly, I am having a difficult time getting my head around this. Maybe it's just end of week burn out. Am I correct in my understanding that you start with an add page and then use edit pages for the proceeding pages. You can put all the data in one table if you use a session variable (the record id). Each page is a view containing the applicable fields/questions.
I did not wish to save the record until the end. The last page would have a normal submit button which would save the data and redirect the user to wherever I wanted to send them. The reason I don't want to add the record until the end is because I know there will be many times when the user will change their mind and want to start over, or worse, just close out of the application. I don't want to have partial records in the database, which is what I will end up with, unless the user completes the entire process.
Is it possible to go from 1 page/view to another saving the data of the previous page(s) in a variable and on the last page write the data to the database?
Either I am making this more complicated (which I tend to do) or is it possible PHPR (as much as I like it) does not lend itself to this type of application?
I will continue to work on this using all the good information supplied to me.
Thanks,

Dave

T
thesofa author 12/5/2008

Thanks for all your replies. Frankly, I am having a difficult time getting my head around this. Maybe it's just end of week burn out. Am I correct in my understanding that you start with an add page and then use edit pages for the proceeding pages. You can put all the data in one table if you use a session variable (the record id). Each page is a view containing the applicable fields/questions.

I did not wish to save the record until the end. The last page would have a normal submit button which would save the data and redirect the user to wherever I wanted to send them. The reason I don't want to add the record until the end is because I know there will be many times when the user will change their mind and want to start over, or worse, just close out of the application. I don't want to have partial records in the database, which is what I will end up with, unless the user completes the entire process.
Is it possible to go from 1 page/view to another saving the data of the previous page(s) in a variable and on the last page write the data to the database?
Either I am making this more complicated (which I tend to do) or is it possible PHPR (as much as I like it) does not lend itself to this type of application?
I will continue to work on this using all the good information supplied to me.
Thanks,

Dave



Yes, you can save all the answers or fields to session variables, then write it all in a custom script at the end.