473,416 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

disabling image buttons

Hi everyone,

I'm new to javascript and have the following problem:
I have two image buttons:
1)
<td><a href="http://localhost/gamerules.php" target="mainwindow"><img
onMouseOver="return changeRules()" onMouseOut="return
changeRulesBack()" name="b_rules" src="images/b_rules.jpg" width=130
height=90></a></td>
2)
<td><a href="http://localhost/playscreen.php" target="mainwindow"><img
onMouseOver="return changePlay()" onMouseOut="return changePlayBack()"
name="b_play" src="images/b_play.jpg" width=130 height=85></a></td>

I need to do the following: when button 2 is pressed button 1 will
become disabled/unclickable, how do I get this kind of behavior?

thanks in advance for any help

Jul 23 '05 #1
3 2027

Well, simple:

<a href="http://localhost/playscreen.php"
onclick="document.images['b_rules'].parentElement.removeAttribute('href')"
target="mainwindow"><img
onMouseOver="return changePlay()" onMouseOut="return changePlayBack()"
name="b_play" src="images/b_play.jpg" width=130 height=85></a>

Danny

On Sun, 26 Jun 2005 11:47:57 -0700, inonzuk <in*****@hotmail.com> wrote:
Hi everyone,

I'm new to javascript and have the following problem:
I have two image buttons:
1)
<td><a href="http://localhost/gamerules.php" target="mainwindow"><img
onMouseOver="return changeRules()" onMouseOut="return
changeRulesBack()" name="b_rules" src="images/b_rules.jpg" width=130
height=90></a></td>
2)
<td><a href="http://localhost/playscreen.php" target="mainwindow"><img
onMouseOver="return changePlay()" onMouseOut="return changePlayBack()"
name="b_play" src="images/b_play.jpg" width=130 height=85></a></td>

I need to do the following: when button 2 is pressed button 1 will
become disabled/unclickable, how do I get this kind of behavior?

thanks in advance for any help


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #2
thanks for the answer, another question is :
1)how can I start with image 1 clickable and image 2 unclickable, and
only after I click image 1 -> image 2 becomes clickable. (i.e.
starting with href empty on image 2 and setting its value when image 1
is clicked).

2)I want to change the image src when the image in unclickable. what is
the correct way to check it (I want to do a "if" condition ... if (href
is empty for that picture) change the src to unclickable image).

I want to do a function "onClick = doThis()"
function doThis(){
if (href is empty){
change the href to clickable link
change the image src to clickable button
}else{
change to empty href
(document.images['b_ru*les'].parentElement.removeAttr*ibute('href')")
change the image src to unclickable button
}
}

Jul 23 '05 #3

Well, images can do onclick, so, not sure on the <a> needed for the
linking, seems to me you can do all this using an onclick on the images, I
use the removeAttribute() in order to remove the 'href' and thus making it
not-hyperlink, however, you do all that with a function onclick of the
image and give the image style="cursor: pointer" to have the mouse change
as if it was a link, as for addressing the images, you can just give them
associative names, like name="image1" name="image2" and use the
document.images collection to iterate or access them, as in for
(i=0;i<3;i++) {.... document.images['image'+i].src='ANOTHERFILE.png'; or
such.

Danny

On Sun, 26 Jun 2005 12:41:38 -0700, inonzuk <in*****@hotmail.com> wrote:
thanks for the answer, another question is :
1)how can I start with image 1 clickable and image 2 unclickable, and
only after I click image 1 -> image 2 becomes clickable. (i.e.
starting with href empty on image 2 and setting its value when image 1
is clicked).

2)I want to change the image src when the image in unclickable. what is
the correct way to check it (I want to do a "if" condition ... if (href
is empty for that picture) change the src to unclickable image).

I want to do a function "onClick = doThis()"
function doThis(){
if (href is empty){
change the href to clickable link
change the image src to clickable button
}else{
change to empty href
(document.images['b_ru*les'].parentElement.removeAttr*ibute('href')")
change the image src to unclickable button
}
}


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #4

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

Similar topics

0
by: Philippe Meunier | last post by:
Hi, I am using the .NET toolbar with VB.NET 2003. My toolbar uses icons images that are actually PNG files and uses alpha blending on it. So to make alpha blending work correctly with the...
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
0
by: Dana Epp | last post by:
I have a ToolBarButton that when I set it to disabled (button.Enabled = false;) causes a really ugly gray masking effect to take place. This is normal and the intended way of the button, but I...
1
by: R.Balaji | last post by:
Hi, We are developing a windows application using c#. We have created a toolbar with some toolbar buttons. When we disable the toolbar button, the toolbar button image should be displayed...
1
by: markeboy | last post by:
What is the workaround to prevent toolbar buttons from displaying a grey square where the image should be once the toolbar button is disabled I have transparent color of the image list set to...
1
by: barq | last post by:
I'm using image in an anchor tag as a submit button. We use document.images.parentElement.removeAttribute('href') in a javascript function to make a image button non-clickable (not-hyperlink)....
3
by: kayahr | last post by:
Hi there, I have a strange problem in Internet Explorer (IE6 and IE7). I'm writing a JavaScript application which allows the user to edit a photo composition. So when the user selects a photo then...
20
by: Geoff Cox | last post by:
Hello, I am not at clear how to tackle this one. Say the note middle C is played, just once. Then when the user clicks on a play image a series of notes are played starting with middle C...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.