0

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.

1
  • So you have an array on the client, and want to pass it to the controller? Commented Jul 15, 2012 at 6:52

1 Answer 1

1

If you have a hidden field already, you can do this in JavaScript:

$('#MODELNAME_packages').val(arr);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.