Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...