CodeIgniter Forums

Full Version: Need experts help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hi guys

I my view page am populating schools drop down box so i want to make particular options to selected(default)
I can do this in javascript but the thing is, am passing value from controller to model to query the result, value means like schoolName ='troy';

Because In controller am hardcoding the schoolName value,so the worry is suppose if hardcoding schoolName value is not present in schools drop down

Am not posting whole thing
function getdata(){
if(roleID == 'ADMIN')
$schoolName = 'TROY'; //hardcoding schoolName value Admin he dint belongs any school
$schoolName = $this->gethelperfile();
function show($schoolName)
data[res] = $this->Msub->getAlldate($schoolName);

function reload(){
$schoolName = $_post['$schoolName'];
$schoolName = $this->uri->segment(3);

view page
<select id='sc' name='sc'>
foreach($value as $obj){
echo "<option value='".$obj['sname']."'>".$obj['sname']."</option>";
echo "

is there any way to get drop down default selected value to controller to avoid hardcoding the schoolName value when the page gets loading

I want like this

Admin he dint belongs any school he can able to see all schools

but my senior said if U make ALL option the data is too large its take much time to load.

so am not removing all option but when the page get loads am going make default school.