I have a hidden field
<input type="hidden" name="smname" />
Now i have a function in a js file count(); How can I assign the return value to the hidden field?
You could give your hidden field an unique id:
<input type="hidden" name="smname" id="smname" />
and then in javascript:
document.getElementById('smname').value = count();
where count is the function you want to invoke and which returns the value:
var count = function() {
return 'some value';
};
If you give the input element an id attribute you will be able to get a reference to it in javascript using the document.getElementById() method then set the value property of the element
HTML
<input id="surname" type="hidden" name="smname" />
Javascript
var input = document.getElementById("surname");
input.value = count();