Welcome Guest, Not a member yet? Register   Sign In
How Best to Pass Variables From a View to a Model
#2

[eluser]Ajaxboy[/eluser]
[quote author="vincej" date="1334964250"]Hi - I have an order form with products on each line. It has a combination of POST variables which can be easily Posted up to my controller up but also some straight variables - see View:

Code:
<?php foreach ( $_SESSION['openorders'] as $key=>$value) {  ?>
<tr align="center">
<td width="30">&lt;?php $data=array('name' =>'quantity','value'=>$value['quantity']); echo form_input($data); ?&gt;</td> //POST VARIABLE
<td>&lt;?php echo $value['prodid']; ?&gt;</td> // STRAIGHT VARIABLES
    <td>&lt;?php echo $value['name'];?&gt;</td>
    <td>&lt;?php echo $value['ordervalue']; ?&gt;</td>
<td>&lt;?php echo $value['pricelb']; ?&gt;</td>
<td align="right">&lt;?php echo form_checkbox('delete','delete',FALSE); // POST VARIABLES
$data = array(
'orderid'  => $value['orderid'],
'productid'=> $value['prodid'],
'name'=>$value['name'],
);
echo form_hidden($data);
   $totalordervalue += $value['ordervalue'];
} ?&gt;
    </td>                      
</tr>
    <tr><td></td><td></td><td>&lt;?php echo "Total Unweighed Order Value:&nbsp;$";?&gt;</td>
    <td>&lt;?php echo $totalordervalue; ?&gt;</td>
    </tr>
    </table> <br/>

&lt;?php

    echo form_submit('submit','Update and Submit to Picking >> ');
    echo form_close();

My code loops through the $_Session['openorders'] building the page - great.

I now modify the quantities.

I need recommendations on what is the best way of getting all the variables for each product line packed up into some kind of array so I can process them.

I thought of using hidden values and POSTING them to the controller - but what is the best way of getting them into an array ?

Many Thanks for your advice ![/quote]

I think using Javascript would be your best option to interact with data already set on the page. And you can also update the elements, and settings on the page with Jascript, before is submitted to the server.. unless you require of more info from the server or need to save the info on its current state, Javascript is what you need.


Messages In This Thread
How Best to Pass Variables From a View to a Model - by El Forum - 04-20-2012, 04:24 PM
How Best to Pass Variables From a View to a Model - by El Forum - 04-20-2012, 11:16 PM
How Best to Pass Variables From a View to a Model - by El Forum - 04-21-2012, 12:00 AM
How Best to Pass Variables From a View to a Model - by El Forum - 04-21-2012, 05:01 PM
How Best to Pass Variables From a View to a Model - by El Forum - 04-21-2012, 08:58 PM
How Best to Pass Variables From a View to a Model - by El Forum - 04-22-2012, 10:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB