Kode
Kode

Reputation: 3215

Set Value of Hidden Field in SharePoint using jQuery

I am able to set the value of a site column (field), using jQuery, when it is not hidden using this:

    $("select[Title='MyID']").val(MyRelatedID);

However, once I hide the field it doesn't work. I inspected the code and it looks like SharePoint hides it from the source code as well. I am opening the list containing the fields in a modal. Has anyone be able to set the hidden value of field?

Upvotes: 0

Views: 4335

Answers (1)

jpussacq
jpussacq

Reputation: 577

I usually use this approach:

To set the value:

$('input[title="MyID"]').attr("value",MyRelatedID);

To hide the field:

$('input[title="MyID"]').parent().parent().parent().css("display","none");

I documented the complete approach here.

Upvotes: 2

Related Questions