get price and calculate total price from a bill in a view

I want to do bill of products, when i select one or many products i want that his price go into the value of CHtml::numberField(‘pu[]’), calculate the price automaticaly .

Please help me.

my view _form:

<div class="row2">

    &lt;div class=&quot;row copy&quot;&gt;


        &lt;br/&gt;


        &lt;?php


        &#036;montantTotal=0;


        &#036;models = Produit::model()-&gt;findAll('quantite_en_stock&gt;0', array('order' =&gt; 'id_produit'));


        &#036;list = CHtml::listData(&#036;models, 'id_produit', 'libelle_produit');


        ?&gt;


         &lt;div&gt;&lt;d style=&quot;margin-right: 140px;&quot;&gt;Produit&lt;/d&gt;|&lt;d style=&quot;margin-right: 68px;&quot;&gt; Prix unitaire&lt;/d&gt;|&lt;d style=&quot;margin-right: 58px;&quot;&gt; Quantité&lt;/d&gt;|&lt;d style=&quot;margin-right: 90px;&quot;&gt; Prix total&lt;/d&gt;&lt;/div&gt;


        &lt;div&gt;


            &lt;?php echo CHtml::dropDownList('produit[]', '', &#036;list, array('empty' =&gt; '(selectionner le produit)','id'=&gt;'listp','style' =&gt; 'width:185px;')); ?&gt;


            &lt;?php echo CHtml::numberField('pu[]', '',array('min'=&gt;1,'disabled' =&gt; 'disabled','id'=&gt;'prixU','style' =&gt; 'width:130px;')); ?&gt;


            &lt;?php echo CHtml::numberField('qte[]', '',array('min'=&gt;1,'id'=&gt;'quantite','oninput'=&gt;'getPrixTotal()','style' =&gt; 'width:102px;')); ?&gt;


            &lt;?php echo CHtml::numberField('prixT[]', '',array('min'=&gt;1,'disabled' =&gt; 'true','id'=&gt;'prixT','style' =&gt; 'width:160px;')); ?&gt;


        &lt;/div&gt;


    &lt;/div&gt;


    &lt;div&gt;&lt;br&gt;&lt;center&gt;&lt;b&gt;Montant total de la facture : &lt;?php echo &#036;montantTotal ?&gt; FCFA&lt;/b&gt;&lt;/center&gt;&lt;/center&gt;&lt;/div&gt;


         &lt;br&gt;


&lt;/div&gt;

in my controller factureController:

public function actionCreate() {

    &#036;model = new Facture;





    // Uncomment the following line if AJAX validation is needed


    // &#036;this-&gt;performAjaxValidation(&#036;model);





    if (isset(&#036;_POST['Facture'])) {


        &#036;model-&gt;attributes = &#036;_POST['Facture'];


        &#036;model-&gt;id_client = &#036;_POST['client'];





        //valeur recupéré


        &#036;produit = &#036;_POST['&#036;produit'];


        //&#036;pu = &#036;_POST['pu'];


        &#036;qte = &#036;_POST['qte'];


        //&#036;prixt = &#036;_POST['prixT'];


        //&#036;tailTab = count(&#036;prixt);


        &#036;tailTab = count(&#036;qte);


        if (&#036;model-&gt;save()) {


            &#036;connexion = Yii::app()-&gt;db;


            &#036;pTotal = 0;


            &#036;montantTotal =0;


            &#036;erreur=&quot;&quot;;


            for (&#036;i = 0; &#036;i &lt; &#036;tailTab; &#036;i++) {


                


                &#036;sqlP = &quot;SELECT prix_unitaire,num_serie,quantite_en_stock FROM produit WHERE id_produit = '&#036;produit[&#036;i]'&quot;;


                &#036;comP = &#036;connexion-&gt;createCommand(&#036;sqlP);


                &#036;comP-&gt;execute();


                foreach (&#036;comP AS &#036;p) {


                    &#036;prixU = &#036;p['prix_unitaire'];


                    &#036;qS = &#036;p['quantite_en_stock'];


                    &#036;numS = &#036;p['num_serie'];


                }


                // on teste si la quantité en stock est supperieure a la quantité choisie


                if(&#036;qS &gt;= &#036;qte){


                    


                    // &#036;sql = &quot;INSERT INTO produit_facture VALUES('&#036;produit[&#036;i]','&#036;model-&gt;id_facture','&#036;qte[&#036;i]','&#036;prixt[&#036;i]','&#036;pu[&#036;i]')&quot;;


                    &#036;sql = &quot;INSERT INTO produit_facture VALUES('&#036;produit[&#036;i]','&#036;model-&gt;id_facture','&#036;qte[&#036;i]','&#036;numS','&#036;prixU')&quot;;


                    &#036;command = &#036;connexion-&gt;createCommand(&#036;sql);


                    if (&#036;command-&gt;execute()) {


                        //&#036;total += (&#036;qte[&#036;i] * &#036;pu[&#036;i]);


                        &#036;pTotal += (&#036;qte[&#036;i] * &#036;prixU);


                        //&#036;montantTotal +=&#036;total;


                        &#036;montantTotal += &#036;pTotal;


                        


                        //mise à jour du stock


                        &#036;req = &quot;SELECT quantite_en_stock FROM produit WHERE id_produit='&#036;produit[&#036;i]'&quot;;


                        &#036;comm = &#036;connexion-&gt;createCommand(&#036;req);


                        &#036;comm = &#036;comm-&gt;query();


                        foreach (&#036;comm AS &#036;qt) {


                            &#036;qteS = &#036;qt['quantite_en_stock'];


                            &#036;qteS -= &#036;qte[&#036;i];


                            &#036;req2 = &quot;UPDATE produit SET quantite_en_stock='&#036;qteS' WHERE id_produit='&#036;produit[&#036;i]'&quot;;


                            &#036;com1 = &#036;connexion-&gt;createCommand(&#036;req2);


                            &#036;com1-&gt;execute();


                        }


                    }





                    //mise à jour du total


                    &#036;sql2 = &quot;UPDATE facture SET total='&#036;pTotal' WHERE id_facture='&#036;model-&gt;id_facture'&quot;;


                    &#036;command2 = &#036;connexion-&gt;createCommand(&#036;sql2);


                    &#036;command2-&gt;execute();


                    // message a afficher sur la vue create


                }   &#036;erreur = &quot;La quantité demandée est supérieure a la quantité en stock&quot;;


                    //&#036;this-&gt;render('create',array('model'=&gt;&#036;model,'erreur'=&gt;&#036;erreur));


                    &#036;this-&gt;renderPartial('_form',array('model'=&gt;&#036;model,'erreur'=&gt;&#036;erreur));


            }


        &#036;this-&gt;redirect(array('view', 'id' =&gt; &#036;model-&gt;id_facture));


        }


    }


    &#036;this-&gt;render('create', array(


        'model' =&gt; &#036;model,


    ));


            


}