Cannot create cascading dropdown.

Oct 15, 2009 at 7:35 PM

 

Hi,

I am using this jquery.

<script language="javascript" type="text/javascript" src="/Documents/jquery-1.3.2.js"></script>
<script language="javascript" type="text/javascript" src="/Documents/jquery.SPServices-0.3.1.min.js"></script>

<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Test List2",
   relationshipListParentColumn: "Supplier",
   relationshipListChildColumn: "Title",
   parentColumn: "Supplier",
   childColumn: "Vendor"
  });
 });

</script>

Test List1 - Title, Supplier

Test List2 - Title and Supplier (Look up from Test List1)

Test List3 - Title, Supplier (Look up from Test List1), Vendor (Look up from Test List2)

But i cannot get the cascading dropdown list.

What could be the problem? 

 

Thank you

Anil

Coordinator
Oct 15, 2009 at 7:54 PM

Anil:

At first glance, everything looks OK.  Is your relationshipList in the same site as your form?  If not, you should specify the WebURL where it sits.  Also, what, if any, errors do you get?

M.

Oct 15, 2009 at 8:57 PM

Marc,

I figured out.

I placed .js file in a library of same site instead of root of site collection.

Now its working fine.

Thanks for reply.

Anil.

Coordinator
Oct 15, 2009 at 9:05 PM
Anil:

Glad you worked it out. Let me know if there is anything else I can
help with.

M.
Oct 26, 2009 at 8:04 PM

anilkumar,

Where did you place your jquery code?

I can figuare out where to place the code on the NewForm.aspx page (if that is where it is suppose to be anyway). In SPD, when i post the code near the top, The first three lines are underlined in red and say "in content pages, content is not allowed outside <script> or <asp:Content> regions."

Thanks

 

 

Coordinator
Oct 26, 2009 at 8:12 PM

Patrick:

I generally put my script in the PlaceHolderMain ContentPlaceHolder, like this:

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript" src="/jQuery%20Libraries/jquery.SPServices-0.4.1.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        ...do something...
    });
</script>
...

Obviously, the src attributes should point to wherever you've put the .js files.

Hope this helps.  Let me know if you have further questions.

M.

Oct 26, 2009 at 8:27 PM

Patrick,

I put the files in a library under root of site collection.

I tried to place the files in a sub site but could not.

Oct 26, 2009 at 8:50 PM

Thanks guys!

Maybe im doing something wrong? Here are my steps to attempt the example with the states and regions on the $().SPServices.SPCascadeDropdowns documentation page.

1) Create 2 lists with the same data shown and column names

2) Create a Third list with Country(choice), Region (lookup), State (lookup)

3) Open the Third list's NewForm.aspx page in SPD

4) Copy jquery-1.3.2.min.js and jquery.SPServices-0.4.1.min.js to the same dir

5) Cerate a <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> place holder

6) Paste this code inside the palce holder:

<script language="javascript" type="text/javascript" src="jquery-1.3.2.js"></script>
<script language="javascript" type="text/javascript" src="jquery.SPServices-0.4.1.min.js"></script>
<script language="javascript" type="text/javascript">
	$(document).ready(function() {
		$().SPServices.SPCascadeDropdowns({
			relationshipList: "Regions",
			relationshipListParentColumn: "Country",
			relationshipListChildColumn: "Title",
			parentColumn: "Country",
			childColumn: "Region"
		});
		$().SPServices.SPCascadeDropdowns({
			relationshipList: "States",
			relationshipListParentColumn: "Region",
			relationshipListChildColumn: "State",
			parentColumn: "Region",
			childColumn: "State"
		});
	});
</script>

 7) Save page / View - Nothing happens

Am I way off??? I think im missing something here in the steps? Or not undersanding what is happening. Thanks for all of your time an knowledge shared here!!


 

Coordinator
Oct 27, 2009 at 3:51 AM

Patrick:

You're heading in the right direction, but I think you may have gotten a little lost.  Are you just trying a proof of concept?  I hope so because you sohlud really put the .js files somewhere more central.

In any case:

4) Do you mean that you have put the .js files in the Third list's "folder" where the NewForm.aspx sits?

5) You shouldn't need to create this placeholder, as it ought to already exist.  If you created one, I'd be surprised if you didn't get an error.

M.