CodeIgniter Forums
Passing javascript variable from my view to my coltroller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Passing javascript variable from my view to my coltroller (/thread-45761.html)



Passing javascript variable from my view to my coltroller - El Forum - 10-05-2011

[eluser]Unknown[/eluser]
Hi everyone,

I have having a problem redirecting from my controller to my view. I think that is when I pass the variable "val" from my view to my controller. If I remove the variable and redirect, it works fine. Any ideas?

View:
Code:
$formSeg4 = array('training', 'ci', 'index.php', 'trainsession_control', 'viewTrainDateReload');
$formUrl4 = site_url($formSeg4);
$dateid;
if ($did[0] != '') {
    $dateid = $did[0];
}
$finmsg = $selected[0];
$alldone = $allclientids[0];
?>
    [removed]

        function reload(form)
        {
            var val=form.companyDDL.options[form.companyDDL.options.selectedIndex].value;
            self.location = '<? echo $formUrl4; ?>/' + val + '/<? echo $dateid; ?>/<? echo $finmsg; ?>/<? echo $alldone; ?>';
        }
[removed]

Controller:

Code:
function viewTrainDateReload($val, $did, $finmsg, $alldone) {
        $warning = 'zzzz';
        if ($finmsg == "error") {
            $warning = $warning . ' The box has too be checked in order to complete the page. <br/>';
        }
        if ($alldone == '111') {
            $warning = $warning . '  Not all clients and guest have been evaluated.';
        }
        $this->load->model('trainsession_model');
        $data['attend'] = $this->trainsession_model->getAttendInfo($did);
        $data['trclient'] = $this->trainsession_model->getClientInfo($did);
        $data['trcompany'] = $this->trainsession_model->getCompanyInfo($did);
        $data['did'][0] = $did;
        $data['companyDDL'][0] = $val;
        $data['allclientids'][0] = $alldone;
        $data['msg'][0] = $warning;
        $data['selected'][0] = $finmsg;
        if ($data['attend'] != 'nothing') {
            $this->load->view('dateAttend_view', $data);
        } else {
            $this->load->view('noAttend_view', $data);
        }
    }