Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 12th, 2005, 09:23 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default disable <div> content (everything inside it!)

Is there a way to 'grey out' or 'disable' an image?

For example i have this code:

<tr>
<td>
Status:
</td>
<td>
<img src="picco.jpeg">
</td>
</tr>

How can i 'grey-out' the image picco.jpeg, or have it appear to be 'disabled' like the text???

I dont think this can be done in HTML, but possibly Javascript. If i put a <div> tag around the image and then javascript code could disable the <div> tag ID onLoad would this work?

I found this code, but I am not sure how to implement it into my code:

Code:
> <div id=s1 disabled>
> <button onclick="alert('1')">click me</button>
> <button onclick="alert('2')">click me</button>
> <button onclick="alert('3')">click me</button>
> </div>
>
> When I open this code in IE6 the buttons indeed appear grayed out
> (disabled), but surprisingly - they do respond to clicks, despite
> MSDN's explicit declaration...

That won't work in any browser other than IE. It's also invalid HTML.

> Does anybody know how can I still control the buttons state or
> enable/disable their mouse events in one command?

Use your original HTML and:

if( !document.getElementById ) {
if( document.all ) {
document.getElementById = function( id ) {
return document.all[ id ];
}
} else {
document.getElementById = function() {
return null;
}
}
}
function enableGroup( prefix, num, bool ) {
bool = bool || true;
for( var i = 1, e; i <= num; ++i ) {
e = document.getElementById( prefix + num );
if( e ) e.disabled = !bool;
}
}

calling the function

enableGroup( 'b', 3 )
or
enableGroup( 'b', 3, true )

to enable b1 through b3 and

enableGroup( 'b', 3, false )

to disable b1 through b3.

Mike
it may be easier to read here:
http://www.forum4designers.com/archi...4-3-64683.html

tia guys!

:-)

Picco


www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
  #2 (permalink)  
Old April 12th, 2005, 09:23 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Also discussed @:

http://www.codingforums.com/showthread.php?t=56782

(if you are interested and a member)


www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
  #3 (permalink)  
Old April 12th, 2005, 09:35 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

It can be done with css, although you will need to take a different approach for different browsers. just google for "opacity css" & you should find what you need.

HTH,

Chris



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
Printing the content inside the div tag cheeky Pro JSP 0 April 26th, 2007 07:26 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<A><DIV><TABLE></DIV></A> anshul HTML Code Clinic 2 July 17th, 2004 02:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.