I've got a piece of PHP code that iterates through a database lookup and each iteration adds a option to a parent select element.
I'm able to add column values from the table to the name the class of each option, which i can then refer to by using option[class*="columnvalue"]
I want to set the background color of the select element that the option belongs to.
So in short i'd like: Parent::option[class*="xyz"]
I've seen something about the < operator but this didnt work.
echo '<select class="dropdown" name="'.$time.'-'.$group.'-'.$iteration.'-'.$new_date.'" >';
$code="";
while ($row = $result->fetch_assoc()) {
unset($firstname, $lastname);
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$memberid = $row['memberid'];
$code = $row['code'];
echo '<option class="drop" value="'.$memberid.'">'.$firstname . ' ' . $lastname .'</option><option value="cancel-'.$memberid.'">Cancel</option>';
}
The following will apply to the option, but the red background only shows when the drop down menu is expanded, not when selected
option[class*="drop"]{background-color:red;}
Also tried this (which i dont believe actually is a valid operator select < option[class*="drop"]{background-color:red;}