Retrieving Variable from Javascript and Pass it to <s:hidden> then through the Actionclass.

I am using jquery struts2 grid plugin. I am using my own form to update, delete and insert object. I had created a hidden field to retrieved the value from javascript but it did not work... I also created a <s:textfield> it could not retrieve the value of the variable from javascript.. What seems to be the problem?

When I click the grid code below is activated.

var product_id = grid.jqGrid('getCell', sel_id, 'product_Id');

I want to pass the value of product_id to the hidden tag in struts2 by this.

document.getElementById('product_Id').value = product_id;

So it should pass the product_id value to product_Key field through this tag.

<s:hidden value="" name="product_Key" id="product_Id"/>

Then when i click the edit button on the grid, it should be passed as a paremeter through this lines.