Skip to main content
Known Participant
September 22, 2009
Answered

How can I control/move the cursor/focus or whatever it's now called?

  • September 22, 2009
  • 2 replies
  • 533 views

I have a page that is a questionnaire (form), and sometimes the answer to one question determines what the next question will be.

e.g. Ques 1.     Are you a veteran of the U. S Armed Forces.  If No, go to question 3; if Yes continue below                                   Yes.     No.

                         a.     What is your date of birth?     ___________

                         b.     What were your dates of service? from _________ thru ________.

                         c.     etc.

     Ques 2.     etc.

     Ques 3.     etc.

I need to be able to test the answer to one question and set the focus accordingly;  In some case, I also need to display data entered on previous pages; e.g. Ques 1., a., above, the DOB was entered in the previous page.  If the answer to question 1 is Yes, I would need to display the DOB, then set the focus at Ques 1., b if the answer to question 1 is Yes.  I'd also like to be able to set the focus in the first field of a form when the page is initially displayed.

How are these things done?????

Also, would it be best to make the entire page one <form>, or a separate <form> for each question???

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer David_Powers

creacontech wrote:

I need to be able to test the answer to one question and set the focus accordingly;  In some case, I also need to display data entered on previous pages; e.g. Ques 1., a., above, the DOB was entered in the previous page.  If the answer to question 1 is Yes, I would need to display the DOB, then set the focus at Ques 1., b if the answer to question 1 is Yes.  I'd also like to be able to set the focus in the first field of a form when the page is initially displayed.

How are these things done?????

With JavaScript. It needs to be scripted specifically for the various options you want.

Also, would it be best to make the entire page one <form>, or a separate <form> for each question???

One form to be submitted when all questions have been answered. However, lengthy forms might be better spread over several pages. However, that introduces the problem of storing all the values until the final form is ready to be submitted. You would typically do that with session variables server-side.

2 replies

David_Powers
David_PowersCorrect answer
Inspiring
September 22, 2009

creacontech wrote:

I need to be able to test the answer to one question and set the focus accordingly;  In some case, I also need to display data entered on previous pages; e.g. Ques 1., a., above, the DOB was entered in the previous page.  If the answer to question 1 is Yes, I would need to display the DOB, then set the focus at Ques 1., b if the answer to question 1 is Yes.  I'd also like to be able to set the focus in the first field of a form when the page is initially displayed.

How are these things done?????

With JavaScript. It needs to be scripted specifically for the various options you want.

Also, would it be best to make the entire page one <form>, or a separate <form> for each question???

One form to be submitted when all questions have been answered. However, lengthy forms might be better spread over several pages. However, that introduces the problem of storing all the values until the final form is ready to be submitted. You would typically do that with session variables server-side.

Known Participant
September 24, 2009

Thanks for the response.  I'm doing some research as we speak to learn about Javascript (using w3schools.com).  After I learn it, I'll probably be back to find out exactly where, in the page, that it goes (no wisecracks please - LOL).  If there're any more/better places to learn about it, please let me know what it/they are.  Thanks again.