title: how to assign return value of a javascript event function to a javascript variable
body: <p>am developing ruby on rails application application where i am call javascript function onclick event and am returing the value. I want to assign that return value to javascript variable predifined variable. 
  My javascript function looks like:</p>
  
  <pre><code>function hideBrowser( var_i )
  {
  k=var_i+1;
  $("#fileinput-button"+k).hide();
  return var_i;
  }
  </code></pre>
  
  <p>and am calling function like this:</p>
  
  <pre><code>'&lt;div class="cancel" id="cancel'+i+'" onclick=i=(hideBrowser('+i+'))&gt;&lt;button &gt;Cancel&lt;/button&gt;&lt;/div&gt;'
  </code></pre>
  
  <p>Please help me to solve this problem.</p>
  
  <p><strong>update</strong></p>
  
  <p>i am trying one application where first one browse button is visible for the user when user browses the image then that image should be display in place of the browse button that is preview of the image i did it by using ajax-jquery file uploader in ruby and another browse will be visible to the user. when user cancels the image then next browse button should disapper and preview should again count as the previously value. that's why i tried this approach and every thing is working but i want to set variable i value as the previous value. this is not working please help me.</p>
  
  <p>All the above code is written in javascript file.</p>