When you navigate to that folder the url has contains the folder name(as query string) of the current folder, you can get the value of folder name from the query string(Root Folder), but this will contain the actual path of folder, i.e the name of document library and then the folder name.
for eg. RootFolder=%2FInfoPath%2FTesting
Here Infopath is is the Documnet Library name and Testing is the folder name. when you get the query string value you need to split the string by % and also you need to avoid '2F' from the last string then, which will get you the value of folder.
Below is the code to get the values from Query String.
function getQueryStringParameter(paramToRetrieve) {
var params =
document.URL.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve)
return singleParam[1];
}
After this do a split using
.split('%');
Then to avoid 2F use .substring(starting pos,len);
Then on document.ready() method you can call the method which performs the above task and one more line, where you take the id or name attribute of the column in the form and set the value of it like.
$( "input[name$='letter']" ).val(stringWhichContainsTheFolderName);