Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select Simple CSS question
#1
I am hoping this will be really simple, and i am just missing the obvious.

<select class='pets' type='text' name='pets' id='pets' placeholder='Select a Pet...'>
	<option value='' disabled selected>Select a Pet...</option>
	<option>Dog</option>
	<option>Cat</option>
</select>
Using the following code as a basic example, what i want to do is when there is no pet selected the select box background be one colour, e.g. 'red'. When a pet has been selected I would like the background to change to another colour, e.g. 'green'.

Any help would be appreciated.
Reply
#2
Something like this Pen
Reply
#3
I am afraid that is not quite what I am after. But that could be my fault for bad wording. I do not want the <option> tags to change colour, instead I would like the main <select> tag to be the one that changes.

So with your example I would like the <select> to appear red on page loading, but when someone selects 'Dog' the <select> would no longer be red but instead be green.

So in python terms:
If option== 'Select a Pet': 
     background-color= red
else: 
     background-color= blue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Very Beginner question on simple variables Harvy 1 276 Apr-12-2024, 12:03 AM
Last Post: deanhystad
  Simple Question - ' defined as "a". ?' Ryan012 10 1,779 May-27-2023, 06:03 PM
Last Post: Ryan012
  Very simple question about filenames and backslashes! garynewport 4 2,055 Jan-17-2023, 05:02 AM
Last Post: deanhystad
  Python Tkinter Simple Multithreading Question AaronCatolico1 5 1,707 Dec-14-2022, 11:35 PM
Last Post: deanhystad
  A simple "If...Else" question from a beginner Serena2022 6 1,814 Jul-11-2022, 05:59 AM
Last Post: Serena2022
  Simple arithmetic question ebolisa 5 2,135 Dec-15-2021, 04:56 PM
Last Post: deanhystad
  Simple code question about lambda and tuples JasPyt 7 3,461 Oct-04-2021, 05:18 PM
Last Post: snippsat
Big Grin question about simple algorithm to my problem jamie_01 1 1,719 Oct-04-2021, 11:55 AM
Last Post: deanhystad
  Simple question 1234 4 2,333 Dec-04-2020, 12:29 PM
Last Post: DeaD_EyE
  Simple Timer Question cranberrica 3 2,254 Jun-22-2020, 06:29 PM
Last Post: cranberrica

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020