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

[eluser]nandish[/eluser]
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

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

function reload(){
if(isset($_post['$schoolName']){
$schoolName = $_post['$schoolName'];
}else{
$schoolName = $this->uri->segment(3);
}
$this->show($schoolName);
}


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

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.

Thanks