View Full Version : Shade row in a select box?
04-03-2003, 04:15 PM
I need to be able to shade the row of a select box depending on the value of it. If it matches a certain criteria, it should be gray, or whatever.
Can I do this?
04-03-2003, 05:06 PM
sure you can script that after checking your criteria like:
document.formname.selectname.options[someoption].style.backgroundColor = 'somecolor';
04-03-2003, 10:10 PM
That answers my question. I should be able to rig it up from there.
Many thanks. :thumbsup:
04-04-2003, 04:47 PM
In this example given, what takes the place of
What I'm doing is pulling a list of data from a database, using ASP, I'm writing an <option> for each row in the recordset.
So far my code looks like:
<option value = "MyValue"
IF ExpDate <> "" then response.write "document.tpainfo.tpa.options[someoption].style.backgroundColor = 'red';" end if %>>
04-04-2003, 05:19 PM
If you're writing with ASP, why not just add a class to the option, then define that class in your CSS. That way, if you want to change how the highlight looks, just open your CSS and leave the ASP alone :D
04-04-2003, 05:20 PM
How would I do that? I'm having a hard time getting the syntax for that.
04-04-2003, 05:27 PM
Well, I don't know ASP (vbscript) but I can show you what it would look like in PHP
if ( $ExpDate != "" )
echo ( '<option value="$value" class="highlight">$text</option>' );
echo ( '<option value="$value">$text</option>' );
Then, in the CSS
04-04-2003, 05:31 PM
:thumbsup: :thumbsup: :thumbsup:
It worked. That little bit of php is easy enough to understand to translate to ASP. Besides, all I needed was the style info.
Many, many thanks. :)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.