2

I currently replaced someone in a existing SharePoint project and I'm having trouble understanding the previous person's work. I will try to explain the setup and explain my question after to make things clear.

We have a list called Class Sessions in the format of a calendar, it contains scheduled classes with their respective dates, instructors, titles and other information. We also have a Enrollment list that that takes care of enrolling students to the Class Session list. So from the Class Session's DispForm.aspx page we can prompt Enrollment's NewForm.aspx page.

Class Session's DispForm snippet showing link to Enrollment's NewForm

Class Session DispForm

Here is Enrollments NewForm

Enrollment's NewForm

The ClassSession used to point to the correct dropdown class session a week ago (to F101 - Admin 101 (3/8/2015)), but now it always defaults to F101 - Admin 101 (1/16/2015). I never changed any aspx file and dont know what caused this function to stop working. Here is the code of interest for Enrolment's NewForm.aspx

 <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script><script type="text/javascript">
function registerNewStudent(event) 
{
    NewItem2(event, "/sites/FCU/TrainingManagement/Lists/Students/NewForm.aspx");
}   
$(document).ready(function() 
{
    var classSessionField = "select[title='"+ "Class Session Required Field" +"']";
    var args = location.search.slice(1, location.search.length).split("&");
    for (var i in args) 
    {
        var nameVal = args[i].split("=");
        if(nameVal[0] == "ParentID") 
        {
            $(classSessionField).val(nameVal[1]);       
            $(classSessionField).parent().parent().parent().hide();
        }
    }
});

What the previous person did here used to work to automatically set the ClassSession dropdown to the parents corresponding class session. But now it just stop working and I have no clue why. I dont understand the javascript enough to debug the problem and really need some help here. I know I made changes to the Current Sessions and Enrollment lists, like change column names and stuff.

I took a look at this guide but could not understand my NewForm.aspx based on the information on the guide.

Anyhelp with my problem would be greatly appreciated.

Thank you!

  • I think I'm in the right track to figuring this out, just need a little help. I think the tittle of the input control for the ClassSession field might have changed. Thing is that I have no idea how to check what it is. Its a hard information to find on Google. Can anyone tell me how do I know what the tittle attribute of the INPUT control? – Adrian Garcia Mar 12 '15 at 13:03
  • Use Firefox's Firebug add on to look at tittle attributes. – Adrian Garcia Mar 12 '15 at 16:03
0

The problem in this situation was that I changed the column name Class Session to ClassSession in the Enrollment list. Therfore, the input control's title for the ClassSession field changed. So things went bad becasuse the variable ClassSessionField in the NewForm file was hardcoded to "select[title='"+ "Class Session Required Field" +"']"; instead of "select[title='"+ "ClassSession Required Field" +"']";.

If you ever want to make sure what the actual title is just get FireFox's Firebug add-on and inspect any field on your browser. It should show the title field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.