0

I have below requirement and kindly help me with solution.

Scenario: I have a list called Student and in that all details are there like student name, address , district, city and country with mobile number. Now in the form i have filed like student name and its binded to student list which will fetch only student name. Now i require your help – If i select a student name in that drop down then all other fields in the form like address, district , city and country should fill up automatically.

Could you please suggest me modified code please as i am beginner to this env.

1

1 Answer 1

0

You can use rest api to achieve this. Query your list on the student list dropdown change event and fetch the other details.

Sample code given below.

function autoFillFieldsFunction(itemId)
{
    var siteurl = _spPageContextInfo.webAbsoluteUrl;

    $.ajax({
        url: siteurl + "/_api/web/lists/getbytitle('DetailsToBeFetchedFromListName')/items("+itemId+")",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data)
        {
            $("select[title='Savings']").val(data.d.Savings);
        },
        error : function (data) 
        {
            alert("Error: "+ data);
        }});
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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