Cascading Dropdowns

Nov 2, 2009 at 4:54 PM

I too fall into the "noob" category.  I've been working on getting my dropdowns to cooperate with little success.  I've set mine up similar to a blog I'd seen on 9/30 - it was with Makes and Models of SUV's 9.  I used the same column names so I could duplicate it - just changed the data within the columns.

I've got 2 lists - Makes and Models

Makes  = 1 column -- Title

Available

Unavailable

 

Models = 2 columns -- Make & Model

Available               At Duty Station

Available               Telework

Available               Temp Duty Station

Unavailable           Leave-Sick-Flu

Unavailable           Leave-Scheduled

Unavailable           Leave-Sick

Unavailable           SDO

Unavailable           Training/Travel

I've got the two jQuery libraries loaded in a document library on the same home site (jQuery[1].SPServices-0.4.1.min & jQuery-1[1].3.2.min). -verbatim from the library list.

Here's the code I've added to the NewForm.aspx page via Content Editor Web Part:

<script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery-0.4.1.min.js"></script>
<script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery.SPServices-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Models",
   relationshipListParentColumn: "Makes",
   relationshipListChildColumn: "Title",
   parentColumn: "Make",
   childColumn: "Model"
  });
 });
</script>

 

I've got my main list (actually a calendar) with two lookup columns: 1) Make - getting info from the Makes list, title column  and 2) Model - getting info from the Models list, model column.

My "Make" field on the NewForm is showing the options Available or Unavailable so that is okay (I think).

Problem is that when I select either one, I get the full list of both available and unavailable options (Models list) instead of the related available or unavailable options (its connecting, just not the right way).

I've tried all types of combinations to get them to separate with no success - based on what I've described, do you see any misdirections?

Thank you so much for time and assistance.

Dave

 

 

 

Coordinator
Nov 3, 2009 at 3:27 AM

Dave:

Here are a few more questions that ought to help us sort this through for you:

  • In the Models list, are the column names Make and Model or Makes and Model? Is the Title column Make or Model?
  • The .js filenames you show don't match: jQuery[1].SPServices-0.4.1.min & jQuery-1[1].3.2.min versus ../../jQuery%20Libraries/jquery-0.4.1.min.js and ../../jQuery%20Libraries/jquery.SPServices-1.3.2.min.js  The latter look like the correct names, but they obviously have to match the files that are stored in the jQuery Libraries Document Library.  If the Document Library is at the root of the primary Site Collection, I'd refer to them this way: <script language="javascript" type="text/javascript" src="/jQuery%20Libraries/jquery-0.4.1.min.js"></script>
  • If you add an alert after the line $(document).ready(function(), does it fire? If not, then your .js references are not right.

M.

Nov 4, 2009 at 3:00 PM

Hello Marc,

"Models" has two columns -  "Make" and "Model" -- I did not use the Title column (I hid it).

The actual library for the jQuery is "Script Library" -- I've modified the script to show that (thank you for that). 

Do I need both the 1.3.2 (downloaded from: Google "downloads-jqueryjs-Project Hosting Site) and the 0.4.1 (downloaded from your codeplex site)?

My "Script Library" is located in the "parent site" --I'm working in a sub-site.  There are only two items in that library:

jQuery[1].SPServices-0.4.1.min

and

jQuery-1[1].3.2.min

Here's my new code:

<script language="javascript" type="text/javascript" src="../../Script%20Library/jquery[1].SPServices-0.4.1.min.js"></script>
<script language="javascript" type="text/javascript" src="../../Script%20Library/jquery.-1[1].3.2.min.js"></script>
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Models",
   relationshipListParentColumn: "Makes",
   relationshipListChildColumn: "Title",
   parentColumn: "Make",
   childColumn: "Model"
  });
 });
</script> 

 

I think you're right - I think something is wrong with my references.

Marc, please elaborate on "setting an alert" on the code line you identified.

 

Thank You

 

Dave

 

Coordinator
Nov 4, 2009 at 4:03 PM

Dave:

You need both the code jQuery library and my library and you need to reference them in that order.  The filenames above look funny; make sure they are right.

By adding an alert, I meant adding a line like:
alert("Hi Dave");

right below the line:
$(document).ready(function() {

This will tell you if the jQuery libraries are loading correctly.  If you don't see the alert, then your .js references aren't right.

M.

Nov 4, 2009 at 7:31 PM

Hello Marc,

I re-downloaded the two scripts - came out the same way. 

In the code I put the 1.3.2 first and the 0.4.1 second per your direction above.

Current:.................

<script language="javascript" type="text/javascript" src="../../Script%20Library/jquery-1[1].3.2.min"></script>
<script language="javascript" type="text/javascript" src="../../Script%20Library/jquery[1].SPServices-0.4.1.min"></script>
<script type="text/javascript">
 $(document).ready(function() {
 alert("hi dave"); 
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Models",
   relationshipListParentColumn: "Makes",
   relationshipListChildColumn: "Title",
   parentColumn: "Make",
   childColumn: "Model"
  });
 });
</script>

 

Please notice alert per your instruction - no it didn't show. 

I notice the [1] in the jQuery title - the title for the download of 0.4.1 on your page does not have that - should it be there?

Can't tell you how much I appreciate your patience and assistance.

 

dave

Coordinator
Nov 5, 2009 at 2:35 AM

OK, if the alert doesn't pop up, then your references to the .js files still aren't right.  Without the right references, nothing is going to work.  You said that the .js files are in the root site, right?  So wouldn't the path to them be:

<script language="javascript" type="text/javascript" src="/Script%20Library/jquery-1[1].3.2.min"></script>
<script language="javascript" type="text/javascript" src="/Script%20Library/jquery[1].SPServices-0.4.1.min"></script>

These paths are just like any other path: they need to reflect where the .js files are stored.  So if the files are at http://servername/Script%20Library then what I've shown above would be right.

The [1] that you have in each filename ought not to cause a problem, but I don't understand why they are there, as the original files don't have that in them.  Are those the filnames you have in the Document Library called Script Library?

M.

Nov 5, 2009 at 2:07 PM

Hello Marc,

Today's the day - I can feel it.

Here's where the jQuery files are located:

https://its.sc.egov.usda.gov/igd/Script%20Library/Forms/AllItems.aspx

I've tried numerous combinations to include the whole thing (https://.....) in the src= and still it doesn't want to work.  As mentioned earlier, I am placing this in a CEWP on the NewForm.aspx page - could that be a roadblock?

I re-downloaded both jQuery files again to see if the [1] showed up again and it did so as you stated, if that's how it is in the library (which it is) and that's how it is in the code, it should not make a difference.

Dave M

Coordinator
Nov 5, 2009 at 2:27 PM

Try this:

<script language="javascript" type="text/javascript" src="/igd/Script%20Library/jquery-1[1].3.2.min"></script>
<script language="javascript" type="text/javascript" src="/igd/Script%20Library/jquery[1].SPServices-0.4.1.min"></script>

M.

Nov 5, 2009 at 8:52 PM

Still no good Marc.

Must be something else.  I've sent an inquire "up the line" to see if there might be another reason why this is not working.  The references point directly to where the files are located.

I'm sure there are not too many other areas to address on this - it should work - unless you've got another suggestion.

I'll let you know what I find out (if anything).

Not giving up!

Thanks for your patience.

 

Dave M

Coordinator
Nov 5, 2009 at 8:57 PM

As you can see from the other discussions, this thing does work, so something you're doing still isn't right.  Keep debugging!

M.