Pass multidimensional array created with Jquery through hidden field to Codeigniter |
[eluser]elambert[/eluser]
I have a form where the user can add items into inventory. Here is a screenshot: http://www.internetgreenhouse.com/add-directv.html They build a list of Equipment Types and Quantities they want to add which is done using Jquery. The problem I am having is creating a multidimensional array with this information e.g. { equipment_type_id: '10', equipment_type_name: 'WDECA - WIRELESS DECA', equipment_quantity: '3' } and passing it to Codeigniter via a hidden form. What is the best way to accomplish this?
[eluser]Eduard Stankovic[/eluser]
check this jquert methd $.post() http://api.jquery.com/jQuery.post/
[eluser]elambert[/eluser]
Ed, thank you for your reply. Actually, I do not want to submit the form via ajax. I am just adding adding items dynamically with Jquery into hidden fields and submitting the form with a standard post. I have a solution developed (see below), I just do not feel that it is very elegant. Currently, I have an array for each field I want save. Ideally, I would add all the fields into a single multidimensional array. Here is how I am doing it right now. Jquery Code: $("#add_button").click(function() { View (this repopulates the arrays into the hidden fields when form validation fails) Code: <? if ( isset( $non_serialized_equipment_types_selected ) && is_array( $non_serialized_equipment_types_selected ) && count( $non_serialized_equipment_types_selected ) > 0 ): ?> In the Controller and Model I just access it the same way I do all the form data... I am sure that others have solved this problem before...Any ideas on how to improve on my current solution? |
Welcome Guest, Not a member yet? Register Sign In |