Reputation: 103
How to hidden the select option tag . When I try to put hidden in select I can still see it in my php page don't know why ? input tag is easy to hidden but the select option is difficult to hide
<select type="hidden" style="text-color:white;"name="syearid" class="select2_group form-control" style="text-align:center;" >
<?php
$YearNow=Date('Y');
include('../connection/connect.php');
$result = $db->prepare("SELECT * FROM school_year");
$result->bindParam(':syearid', $res);
$result->execute();
for ($i=0; $row = $result->fetch(); $i++) {
$isSelected = (($YearNow=Date('Y') == $row['from_year']) ? " selected" : "");
echo "<option style='text-color:white;' value='".$row['syearid']."'$isSelected>".$row['from_year'].'-'.$row['to_year']."</option>";
}
?>
</select>
Upvotes: 0
Views: 113
Reputation: 40030
<select name="syearid" class="select2_group form-control" style="text-align:center;text-color:white;display:none;" >
display:none;
will hide the select tag.
Note that you can also do this (better):
<style>
#syearid{text-align:center;text-color:white;display:none;}
</style>
<select id="syearid" name="syearid" class="select2_group form-control" >
To pre-set the value, and disable the control, you can do this:
<select disabled>
<option>Car</option>
<option selected>Bus</option>
<option>Van</option>
</select>
Upvotes: 2