locked
Populate dropdown using script RRS feed

  • Question

  • Hello Everyone,

    I have a three lists: countires,states & locations, My requirement is to populate these three lists in the newform. If I select country corresponding states should populate in the states dropdown & if i select state corresponding locations should populate in the locations dropdown without using server side code.

    Please help me on this issue!

    Thanks In Advance,
    Kumar
    Wednesday, January 21, 2015 4:27 AM

Answers

All replies

  • Hi,

    IT can be achieved through SPServices. Please refer to links given below:

    http://sharepoint-works.blogspot.in/2012/02/cascading-dropdown-or-filtered-values.html

    https://spcd.codeplex.com/

    Hope it helps!

    Thanks,

    Avni Bhatt


    If this helped you resolve your issue, please mark it Answered

    • Proposed as answer by Mokhtar Bepari Wednesday, January 21, 2015 6:25 AM
    • Marked as answer by KumarSP2013 Wednesday, January 21, 2015 11:00 AM
    Wednesday, January 21, 2015 5:50 AM
  • Hi,

    Thank a lot for your help. I have followed the article and uploaded the necessary script files but I am getting the "object expected error", can you please help me about the issue with the below code!

    <script src="/Shared%20Documents/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="/Shared%20Documents/jquery.SPServices-0.5.3%20min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "States",
            relationshipListParentColumn: "Country",
            relationshipListChildColumn: "State",
            parentColumn: "Country",
            childColumn: "State"
        });

    $().SPServices.SPCascadeDropdowns({
            relationshipList: "Cities",
            relationshipListParentColumn: "State",
            relationshipListChildColumn: "City",
            parentColumn: "State",
            childColumn: "City"
        });
    });
    </script>

    Thanks,

    Kumar.



    • Edited by KumarSP2013 Wednesday, January 21, 2015 9:50 AM
    Wednesday, January 21, 2015 9:48 AM
  • Hi,

    Please make sure to Place Content Editor Web Part below the list form or else the Java Script added won’t work.

    Also, Please ensure the names in column field should be same as display names in list.

    Can you please tell at which line you are getting this error?Also, if there is reference of a jQuery library in master page, you can remove following line as it will create duplication of jQuery file.

    <script src="/Shared%20Documents/jquery-1.4.2.min.js" type="text/javascript"></script>


    If this helped you resolve your issue, please mark it Answered


    • Edited by Avni Bhatt Wednesday, January 21, 2015 9:57 AM
    Wednesday, January 21, 2015 9:55 AM
  • Hi,

    1) I tried the content editor wp below & above list form(with script file as link).

    2) Field name same as display name

    3) I tried the both ways with & without reference to "/jquery-1.4.2.min.js" but getting the below error message

    Message: Object expected
    Line: 571
    Char: 1
    Code: 0

    I have checked the source it is pointing to the line "$(document).ready(function(){"

    Please suggest what I missed!

    Regards,

    Kumar.


    • Edited by KumarSP2013 Wednesday, January 21, 2015 10:06 AM
    Wednesday, January 21, 2015 10:06 AM
  • Hit the F12 button in the browser and check if the jQuery file was loaded into the script section.If you do not see it jQuery file was not loaded properly. Try using the jQuery file hosted by google cdn. 

    Also, Please try it on IE, FireFox and Chrome browsers.


    If this helped you resolve your issue, please mark it Answered

    Wednesday, January 21, 2015 10:13 AM
  • Thanks a lot Avni, It is working fine.
    Wednesday, January 21, 2015 11:00 AM