473,573 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple colors on <select> list

PW

Is it possible to make a select list item red based on a condition ?

TIA,
PW

May 30 '06 #1
2 1647

PW wrote:
Is it possible to make a select list item red based on a condition ?

TIA,
PW


Are you asking whether one can apply different styles to items in a
select list, or how to code conditional statements with server-side
code?

If the first, try googling optgroup and css, and see if this answers
your question. If it doesn't, you would be better off asking in a css
or stylesheet group.

If it's the second (although I suspect not) show the code you've tried,
and explain where it fails.

--
Mike Brind

May 30 '06 #2
PW

"Mike Brind" <pa*******@hotm ail.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .

PW wrote:
Is it possible to make a select list item red based on a condition ?

TIA,
PW


Are you asking whether one can apply different styles to items in a
select list, or how to code conditional statements with server-side
code?

If the first, try googling optgroup and css, and see if this answers
your question. If it doesn't, you would be better off asking in a css
or stylesheet group.

If it's the second (although I suspect not) show the code you've tried,
and explain where it fails.

--
Mike Brind


Hi Mike,

Thanks for your response. I have since googled and found an answer.

I've created the css as suggested ...

<head>
<STYLE type="text/css">
OPTION.red{back ground-color:white; color:red}
OPTION.black{ba ckground-color:white; color:black}
</STYLE>
</head>

I then created a string based on the condition ...

if len(rs1("NOTES" )) > 0 then
myOptionText = " class=red "
else
myOptionText = " class=black "
end if

And then concatenated the string into the <option> statement based on the
condition ...

if mySearchString <> "" then
if rs1("ESCI") = mySearchString then
response.write "<option selected " & myOptionText & ">"
else
response.write "<option " & myOptionText & ">"
end if
elseif rs1("ESCI") = left(myQueryStr ing,6) then
response.write "<option selected " & myOptionText & ">"
else
response.write "<option " & myOptionText & ">"
end if
Thanks,
PW

May 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3097
by: K. Lobe | last post by:
list box based on a POST method to the same page. frm.cmbList.Value=Request.Form("cmbList") doesn't work. When the page loads, it reloads the <SELECT>, so not sure how to get the list to go to the item. Any ideas? many thnx,
0
2250
by: Stephen Witter | last post by:
I have a multiple select list and I am trying to post to a page where I have no option to use the request.form or vbscript to iterate through the control. The page is a sql server reporting services report. My question is, how can I populate a hidden textbox with multiple selected values of a select list 1) without using two forms, one...
5
8299
by: Brian Foley | last post by:
Hello, I am used to using the label tag with check boxes and radio buttons in html forms. This allows me to click on the text of the label to activate/deactivate the check box / button, rather than having to click on the (possibly small) box or button. I recently tried to assign a label to a select "drop down list", but found that when...
1
3786
by: | last post by:
Hi guys, i have a multiple select list box on my form, and it saves the selections I make into the field just fine., but when i open the form on an existing record, it does not show up the selections that are in the record already ... any ideas how to get a multiple select list box to show the selectinos in
3
2975
by: veg_all | last post by:
Say I have: <select> <option value='a' > First <option value='b' > Second <option value='c' > Third </select> Is there a way I can access the values First, Second and Third from an array ? I want to write a javascript function that can
11
4490
by: Richard Maher | last post by:
Hi, I have read many of the copius entries on the subject of IE performance (or the lack thereof) when populating Select Lists. I don't mind the insert performance so much, (I get 100x120byte rows inserted/sec up to 500, and 100rows/6secs up to 3000, which isn't great but then the Row Count is clicking away for the user to see and they...
2
15886
by: sathyashrayan | last post by:
Dear group, I have a task where I have to fetch datas from mysql and display it in the multiple select list box. I have fetched the datas and it is getting diplayed correctly in the multiple select box. I have used some thing like this. print "<select MULTIPLE SIZE='6' name='db_test'>"; while($row = mysql_fetch_object($handle)) {
3
12245
by: asivakrupa | last post by:
Hi, I am using a multiple select list box. I use an array to retrieve the values that are selected by the user. <select name="competitor"> When I try to validate the list box if the user does not select anything, I get errors. The error deals with the array declared.
0
7705
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6424
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5601
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5294
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3734
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3739
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1044
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.