You cannot set values ββon server side using javascript. You can bind these values ββto input fields (text fields, hidden fields, text fields, drop-down lists, ...) using HTML helpers, and then using javascript you can change the values ββof these input fields.
So, for example, if you have a hidden field:
<input type="hidden" name="foo" id="foo" value="bar" />
You can change its value as follows:
$('#foo').val('some new value');
Then, when the containing form is submitted to the server, the new value will be bound to your view model.
Darin Dimitrov
source share