SuGo
SuGo

Reputation: 139

Creating SharePoint List (Form) which is Dynamic - preceeding choice determines next set of questions

I am attempting to create a list in sharepoint 2010 (which is serving a form that a user can fill out). However, I am attempting to make it dynamic such that:

Question 1 (or technically, column 1 in the list): YES/NO question. IF NO, display Questions 2-15 (or technically, columns 2-15). IF YES, display another set of questions, let's call them Questions 16-18 (only 3).

So, it would be dynamic based only on this first question. I want only this first yes/no question to appear when the user attemps to 'add a new item' to the list. Then, once they answer this first question, it would make the new set of questions appear based on this first questions response.

I am taking the route of doing this via JavaScript. So far, I have this code:

<script type="text/javascript">

$(document).ready(function()
{
$('td.ms-formlabel:contains("Title")').parent().hide();
$('td.ms-formlabel:contains("Start Time")').parent().hide();
$('td.ms-formlabel:contains("End Time")').parent().hide();
});
</script>

This is just a test script I've been using. Basically just using a smaller number of fields to test on a test list I'm using in SharePoint to get the hang of how I want this form to be, so that's why you only see 3 columns so far in the code.

So far, the code I've been playing with is just hiding fields (which I have assumed needs to be done because in the beginning, I want all the questions to be hidden except question 1, right? At least that's how I'm thinking about it and I'm sure you guys know better than me).

So, I'm thinking hide all except that first question. Then I should add an IF STATEMENT, basically saying IF NO, display questions ABC. IF YES, display questions XYZ. However, I'm stuck on how to do this. I'm a total beginner in programming but I've been trying to google and do my best to learn.

Any help is very much appreciated. Thank you!!

P.S. People have said InfoPath is an option. I don't have InfoPath and this route won't be an option for me. People have said it might be possible to do this using Content Types. I haven't looked into this option just yet.

Upvotes: 1

Views: 9121

Answers (1)

rhythmedium
rhythmedium

Reputation: 23

You can also do it with lists: Implement Cascading Dropdowns

Either way, I would use the sharepoint template as user1985793 said or the javascript cascading dropdowns plugin.

EDIT:

Your app would look like this

Question 1: select box - yes or no shown

Question 2: select box - populates choices on question 1 selection

Question 3: select box - populates choices on question 2 selection

You would then make 3 lists. One list for each question.

1st list: yes or no

2nd list: all possible choices with "parent" column set to a 1st list name

3rd list: all possible choices with "parent" column set to a 2nd list name

Upvotes: 0

Related Questions