Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-03-2003, 04:15 PM   PM User | #1
BigDaddy
Regular Coder

 
Join Date: Sep 2002
Location: Bugaha, NE
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
BigDaddy is an unknown quantity at this point
Shade row in a select box?

Hi.

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?
__________________
This is in spanish when you're not looking.
BigDaddy is offline   Reply With Quote
Old 04-03-2003, 05:06 PM   PM User | #2
boywonder
Regular Coder

 
Join Date: Jun 2002
Location: New York, USA
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
boywonder is an unknown quantity at this point
sure you can script that after checking your criteria like:

document.formname.selectname.options[someoption].style.backgroundColor = 'somecolor';
boywonder is offline   Reply With Quote
Old 04-03-2003, 10:10 PM   PM User | #3
BigDaddy
Regular Coder

 
Join Date: Sep 2002
Location: Bugaha, NE
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
BigDaddy is an unknown quantity at this point
That answers my question. I should be able to rig it up from there.

Many thanks.
__________________
This is in spanish when you're not looking.
BigDaddy is offline   Reply With Quote
Old 04-04-2003, 04:47 PM   PM User | #4
BigDaddy
Regular Coder

 
Join Date: Sep 2002
Location: Bugaha, NE
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
BigDaddy is an unknown quantity at this point
In this example given, what takes the place of

option[someoption] ?

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.

If the row has and expiration_date, I want to use javascript to set the background color of that <option> to a different color.

So far my code looks like:

<option value = "MyValue"

<%

IF ExpDate <> "" then response.write "document.tpainfo.tpa.options[someoption].style.backgroundColor = 'red';" end if %>>
MyValue
</option>
__________________
This is in spanish when you're not looking.
BigDaddy is offline   Reply With Quote
Old 04-04-2003, 05:19 PM   PM User | #5
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
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
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 04-04-2003, 05:20 PM   PM User | #6
BigDaddy
Regular Coder

 
Join Date: Sep 2002
Location: Bugaha, NE
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
BigDaddy is an unknown quantity at this point
How would I do that? I'm having a hard time getting the syntax for that.
__________________
This is in spanish when you're not looking.
BigDaddy is offline   Reply With Quote
Old 04-04-2003, 05:27 PM   PM User | #7
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Well, I don't know ASP (vbscript) but I can show you what it would look like in PHP
PHP Code:
if ( $ExpDate != "" )
    echo ( 
'<option value="$value" class="highlight">$text</option>' );
else
    echo ( 
'<option value="$value">$text</option>' ); 
Then, in the CSS
Code:
option.highlight {
    background-color: red;
    }
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 04-04-2003, 05:31 PM   PM User | #8
BigDaddy
Regular Coder

 
Join Date: Sep 2002
Location: Bugaha, NE
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
BigDaddy is an unknown quantity at this point


Nifterooni!


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.
__________________
This is in spanish when you're not looking.
BigDaddy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:01 AM.


Advertisement
Log in to turn off these ads.