php - Pass a variable from one page to another in CodeIgniter -


in codeigniter, on page /categories have table rows of category items. there <select> box filter categories components:

<form accept-charset="utf-8" method="post" action="/categories/get_categories">     <select onchange="this.form.submit()" name="selectcatsbycomponent">         <option value="0" selected="selected">-- choose component --</option>         <option value="1">content</option>         <option value="2">e-commerce</option>     </select> </form> 

so whenever select <option> <select> list , , click on button add new category, want pass post value next page , automatically select corresponding component id in same <select> list.

i tried seems not working:

    if( $this->input->post('selectcatsbycomponent') )         $com_id = $this->input->post('selectcatsbycomponent'); 

any tips ?

======= update =======

guys, still in searching solution - check out template library on github:

https://github.com/danieltorscho/ci_template_lib

it need, nothing, less, nothing more.

i guess options have use check when select written.

<?php /* use default, , try value of previous selection. */ $com_id = 0; if( $this->input->post('selectcatsbycomponent') )     $com_id = $this->input->post('selectcatsbycomponent');  $catsbycomponentoptions = array('-- choose component --','content', 'e-commerce'); ?>  /* start form */ <form accept-charset="utf-8" method="post" action="/categories/get_categories">     <select onchange="this.form.submit()" name="selectcatsbycomponent">  <?php  /* write out each option, checking see if needs selected. */ foreach ($catsbycomponentoptions $key => $value){     echo '<option value="'. $key .'" ';     if ($key === '$com_id')         echo ' selected="selected" ';      echo ">$value</option>"; } ?>  </form> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -