I have a javascript array variable that is created in an action => new
form but I can't seem to find a way to return this variable as a field to the controller along with the other form field inputs. How do I set this array to a hidden field in the form. Is there a way to pass the array back into the parameters hash to the controller?
$(document).ready(function() {
arr = new Array();
$(document).on('change', 'select[id ^="package"]', function() {
var arr = $('select[id ^="package"]').map(function(){
return this.value
})
});
});
I have this javascript array and I want to submit the form with :packages
set to the javascript variable arr
.
如果您已经有一个隐藏字段,则可以在JavaScript中执行此操作:
$('#MODELNAME_packages').val(arr);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.