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:
function hideBrowser( var_i )
{
k=var_i+1;
$("#fileinput-button"+k).hide();
return var_i;
}
and am calling function like this:
'<div class="cancel" id="cancel'+i+'" onclick=i=(hideBrowser('+i+'))><button >Cancel</button></div>'
Please help me to solve this problem.
update
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.
All the above code is written in javascript file.
I am not getting exactly from your code. But see below code it’s working.
Hope it will help you.