Welcome Guest, Not a member yet? Register   Sign In
Populate query result to drop down list with Ajax
#4

[eluser]Sumon[/eluser]
Ops there are one way in my mind to follow MVC for current situation.
Code:
// this is Modle function Called by controller
function searchcontest ($storeid) {
        $query = $this->configmodel->get_contest($storeid);
        $output = Array('contest');
        foreach ($query->result() as $row){
           $arr = Array('contest' => $row->contest);
           $output[] = $arr;
        }
        return $output;
    }
and here is the view page which called by controller using $this->load->view("contest_dropdown");
Code:
// Lets say contest_dropdown.php
<select id='contest' name='contest'>
&lt;?
$TotalRecord=count($ContestData);
for($I=0;$I<$TotalRecord;$I++)
   foreach($ContestData[$I]->result() as $Contest):
?&gt;
  <option value="&lt;?=$Contest->value?&gt;">&lt;?=$Contest["label"]?&gt;</option>
&lt;? endforeach; ?&gt;
</select>
Hope helps you.


Messages In This Thread
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 12:42 AM
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 01:59 AM
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 07:27 PM
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 11:31 PM
Populate query result to drop down list with Ajax - by El Forum - 07-03-2008, 12:05 AM
Populate query result to drop down list with Ajax - by El Forum - 07-03-2008, 01:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB