Container is a string and you are treating it as a jQuery object. That is your problem.
var container = document.getElementById(id).value; //String here
var ddscore = container.closest('#field1').val(); //Act like it is jQuery here
and farther down in the code
writeLinkScore(id,field1, field2); //where is field1 and field2 defined?
And you are not passing a string, you are passing in an object
<button onclick="showInput(link)">Click me</button>
<button onclick="showInput('link')">Click me</button>
and
function showInput(id) {
var field1 = $('#field1').val();
var field2 = $('#field2').val();
writeLinkScore(id, field1, field2);
}