Get the value of selected Dropdown and pass it to another dropdown as selected in codeigniter

自作多情 提交于 2020-01-06 08:19:09

问题


I have two dropdown boxes both are same values but on different pages...on Page 1 I Created a Button Name as Admit Student to pass the selected value to Page 2 Dropdown which has same dropdown Values I used $_GET to pass the selected value for page 2 this option working fine for text values but not for dropdown selected. what I want is when I select the value on Page 1 and click, the selected option will auto-select the same value on page 2 From Dropdown options

This is my code in the first page for dropdown:

<form action="/student/create" method="get" id="nameform">
<div class="row"><select name="enquiry_type" class="form-control" id="enquiry_type">
<option value="enquiry_type"><?php echo $this->lang->line('select') ?></option>                                                                      
<?php foreach ($enquiry_type as $key => $value) { ?>                  
<option value="<?php echo $value['enquiry_type']; ?>"                      
<?php if (set_value('enquiry_type', $enquiry_data['enquiry_type']) == $value['enquiry_type'])                                                         
{ ?>selected=""<?php } ?>><?php echo $value['enquiry_type']; ?></option><?php }?></select>                                                          
</form>                                                               
<button  class="btn btn-primary" type="submit" form="nameform" value="Submit" style="margin-right: 16px">Admit Student</button>

My Code on Second Page

<select name="enquiry_type" class="form-control" id="enquiry_type">
<option value="enquiry_type"><?php echo $this->lang->line('select') ?></option>                                                                      
<?php foreach ($enquiry_type as $key => $value) { ?>                  
<option value="<?php echo $value['enquiry_type']; ?>"                      
<?php if (set_value('enquiry_type', $enquiry_data['enquiry_type']) == $value['enquiry_type'])                                                         
{ ?>selected=""<?php } ?>><?php echo $value['enquiry_type']; ?></option><?php }?></select>

Code on Page 2 to transfer the option of selected value on page 1

<?php $enquiry = ( $_GET['enquiry_type'] == 'enquiry_type' ) ? 'selected' : ''; ?>

and I also tried

$var_enquiry_type = $_GET['enquiry_type'];

Both Tried But Nothing works. Please Help

Thanks in Advance

来源:https://stackoverflow.com/questions/58092568/get-the-value-of-selected-dropdown-and-pass-it-to-another-dropdown-as-selected-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!