The <option>
I want to hide is the option labeled "Select Opportunity". I want to hide this option when I have clicked on the drop down created from the <select>
tag that contains the options from the array I created.
You can see the code I created here:
<form action="/shop/<?php echo $duration_link; ?>" method="get">
<select name="filter_duration" id="filter_duration">
<?php
if(empty($_GET['company'])) {
?><option value="hi" selected>Select Duration</option>
<?php
}else{
?>
<option value="" disabled selected>Select Duration</option> <!--
This disables the option, but it woiuld be ideal to hide it when clicked.
<option value="">Clear Duration</option>
<?php
}
foreach ($duration_array as $duration_title => $duration_time) {
?><option value="<?=$duration_time?>"><?=$duration_title?>
</option> <!-- This sets the different options for the drop down with the
duration array -->
<?php
}
?>
</select>
<!-- Duration: <input type= "text" name= "filter_duration"> -->
<input type="submit"> <!-- This creates a button to submit the information -
->
</form>
<?php
$duration = $_GET['filter_duration'];
$duration_link = '?filter_duration=' . $duration .
'&query_type_duration=or#individuals-top';
?>
I tried writing some JavaScript for it, but I'm really new to it, so I think I might be going wrong somewhere.
You can see the JavaScript I wrote here:
var e = document.getElementById("filter_duration");
var strDuration = e.options[e.selectedIndex].text;
e.onclick = function(){
if(strDuration == "Select Opportunity") {
strDuration['Select Opportunity'].style.display = block;
}
};
If you have any ideas on how I can hide this <option>
it would be a major help!
Many Thanks,
Joshua Gomes