php - How to set selected value in html dropdown if name is array using codeigniter?
问题描述
<h3 class="border_heading"> Academic Details</h3>
<label class="col-sm-2 control-label">10th Class <span class="red-color">*</span></label>
<select class='form-control' name='year[]' id='year' value='' required>
<option value=''>Year</option>
<?php
for($i=2020;$i>=1970;$i--){
echo "<option value='$i' ".set_select('year[]',$i, ( !empty($data) && $data == $i ? TRUE : FALSE )).">$i</option>";
}
?>
</select>
<label class="col-sm-2 control-label">12th Class <span class="red-color">*</span></label>
<select class='form-control' name='year[]' id='year' value='' required>
<option value=''>Year</option>
<?php
for($j=2020;$j>=1970;$j--){
echo "<option value='$j' ".set_select('year[]',$j, ( !empty($data) && $data == $j ? TRUE : FALSE )).">$j</option>";
}
?>
</select>
In the above code I am trying to set value of dropdown. Now, What happen when I select different value of both dropdown then click on submit button then first dropdown show second dropdown value. So, How can I set different value using set_select function? Please help me.
Thank You
解决方案
推荐阅读
- javascript - 如何在 n:m 关联中进行单向限制?
- matlab - 如何使用批处理文件打开已打开的 MATLAB 文件?
- ubuntu - 在 Ubuntu 上,如何将 ~/.dotnet/tools 添加到 PATH 变量中?它不在 /etc/environment 或 ~/.bashrc 中,但它仍然在我的 PATH 中
- raku - 哈希中的接受与智能匹配:有什么区别?
- r - knitr opts_knit$set(root.dir = "../") 当 chunk_output_type: 控制台被忽略
- .net - System.Speech.Synthesis 的事件信息中的流编号在哪里?
- java - 如何在 API 28 中设置 android 日期和时间选择器的样式
- jboss - 使用不同于 UPN 或 samAccountName 的用户名进行身份验证
- azure - CLI 是否针对吞吐量进行了优化?
- tensorflow - tensorflow.python.framework.errors_impl.ResourceExhaustedError