php - Increment index on multidimensional array using AJAX in cakePHP -


first sorry if question isn't clear @ all.

so, have app transaction module in cakephp. module (at least) have 3 chained dropdowns supplier > products > packages. user choose supplier, in products select box show result products selected supplier. packages, options show when choose products.

simply, use this reference first chain. works. when going packages, isn't easy first lol. why? because second form products , packages element have more complex dimensional array first. in first form (supplier element), fetch data $this->request->data['order]['supplier_id']

but in second form, data passed ajax $this->request->data['orderdetail'][$index]['product_id'] index in second form have increment number.

example:

<select id="product0" name=data[orderdetail][0][product_id]></select>  <select id="product1" name=data[orderdetail][1][product_id]></select>  <select id="product2" name=data[orderdetail][2][product_id]></select> 

then in controller,

public function functionname() {     $product_id['index'] = $this->request->data['orderdetail']['index']['product_id']; } 

edited

sorry, forgot post ajax code.

<?php $this->js->get('#ordersupplierid')->event('change',      $this->js->request(array(         'controller'=>'products',         'action'=>'gpbs'),     array(         'update'=>'.orderdetailproduct',         'async' => true,         'method' => 'post',         'dataexpression'=>true,         'data'=> $this->js->serializeform(             array(                 'isform' => true,                 'inline' => true)             )         )  )); 

how can pass dynamic index in ajax?? so, when sent controller, data every "form element" match. thanks, , sorry bad language (and description)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -