From: Geoff on
Hello

I have a questionnaire which consists of several sets of questions,
each set in a form in a separate <div>. Apart from the first <div>
these divs are invisible and become visible once required.

Each form calls a function via a button with onclick="function1();"
etc. The functions validate the data and store the values so that once
all questions have been answered they go to a mysql db via a php file.

The reason I have used this approach is because in several instances a
question will give a yes / no answer. If yes, one question has to be
answered, if no, another one. This I can do by making the appropriate
question <div> visible.

Problem! How can I allow the user to move back to a previous question
if they wish to change the answer given? The back button of course is
no good. I have added a little code to give a warning "not to go back,
otherwise your results will be lost etc" but this does not solve the
problem.

Any ideas please?

Cheers

Geoff
From: Dr_KralNOSPAM on
Geoff,

It sounds like you are uploading data (answers) BEFORE respondent has
finished the form and explicitly clicked SUBMIT. I say you should never do
that.

As the respondent answers each question, you can decide which other
questions should be shown. If the respondent goes back and changes an
answer, then you make the necessary changes to the display. You should not
clear/reset the previously shown sections when you do this as the
respondent may change back and would expect the previous answers to be
there.

It is your responsibility to only present a logical set of question and
then transmit only the DISPLAYED data to the server to process for that is
what the respondent has sent.

Of course, this only is workable if JS is active on the agent's side. If
not, then the problem must be dealt within the server.

K.
The back operation is logically meaningful only if the page has been
written and if it has does work like you want in IE.
From: Geoff on
On Thu, 18 Mar 2010 14:27:40 -0400, Dr_KralNOSPAM(a)nyc.rr.com wrote:

>Geoff,
>
>It sounds like you are uploading data (answers) BEFORE respondent has
>finished the form and explicitly clicked SUBMIT. I say you should never do
>that.

Thanks for your reply.

The onclick for each form (for each set of questions) runs the
function which checks that answers have been given and then saves the
results. Once all questions for the whole questionnaire have been
answered I am using Ajax Updater to send all the data to mysql using
a php file.

>As the respondent answers each question, you can decide which other
>questions should be shown. If the respondent goes back and changes an
>answer, then you make the necessary changes to the display. You should not
>clear/reset the previously shown sections when you do this as the
>respondent may change back and would expect the previous answers to be
>there.

Yes, this is the problem in that I am making each set of
questions/answers disappear once they have been completed, using
hidden <div> class css/javascript. I do this in order that if a yes/no
question/answer leads to 2 different questions I do not want both
questions to be visible. So if the answer is yes, only the yes
question becomes visible. Only one set of questions is visible at any
one time.

Not clear to me how I deal with this so that the user has the chance
to change any of the answers given.

Incidentally if I have a simple table with just one form for all the
questions then of course the user can make changes before submission.
Problem then is that if the user answers yes to a question both the
yes and the no following questions are visible and there is nothing to
stop the user answering either the 'wrong' question or both the
'right' and the 'wrong' question. See what I mean?

Cheers

Geoff

From: Dr_KralNOSPAM on
Geoff,

It is much simplier than you think. For example:

<script type="text/javascript">
function fnsing(inx) {
if (inx==0) { document.getElementById("q34a").className="xhide";
document.getElementById("q34b").className="show";}
else { document.getElementById("q34a").className="show";
document.getElementById("q34b").className="hide";} }
</script>

</head>
<body>

<!-- In the middle -->
<div id=q34>
<p>Question 34
<input type="radio" name="single" id="single0" onclick="fnsing(0)">
Yes&nbsp;&nbsp;
<input type="radio" name="single" id="single1" onclick="fnsing(1)">
No</td></tr></p>

<!-- Single == yes -->
<div id="q34a"> <p>quest for yes</p></div>
<!-- Single == no -->
<div id="q34b"> <p>quest for no</p></div>
</div>


Of course, you need to define the css stuff for show and xhide class
display.

You can even toggle the q34 div show/noshow .

If you have a several part question then you can compress the code with
loops to hide everthing and then show just the one needed.

K.
From: Geoff on
On Thu, 18 Mar 2010 18:00:31 -0400, Dr_KralNOSPAM(a)nyc.rr.com wrote:

>Geoff,
>
>It is much simplier than you think. For example:
>
><script type="text/javascript">
>function fnsing(inx) {
>if (inx==0) { document.getElementById("q34a").className="xhide";
> document.getElementById("q34b").className="show";}
>else { document.getElementById("q34a").className="show";
> document.getElementById("q34b").className="hide";} }
></script>
>
></head>
><body>
>
><!-- In the middle -->
><div id=q34>
><p>Question 34
><input type="radio" name="single" id="single0" onclick="fnsing(0)">
>Yes&nbsp;&nbsp;
><input type="radio" name="single" id="single1" onclick="fnsing(1)">
>No</td></tr></p>
>
><!-- Single == yes -->
><div id="q34a"> <p>quest for yes</p></div>
><!-- Single == no -->
><div id="q34b"> <p>quest for no</p></div>
></div>
>
>
>Of course, you need to define the css stuff for show and xhide class
>display.
>
>You can even toggle the q34 div show/noshow .
>
>If you have a several part question then you can compress the code with
>loops to hide everthing and then show just the one needed.
>
>K.

K,

Brilliant!

Many thanks

Geoff