问题
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