Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old September 18th, 2003, 02:54 PM
RichardJones RichardJones is offline
Senior Member
 
Join Date: Dec 2000
O/S: Windows XP Pro
Location: Woking, Surrey, UK
Age: 28
Posts: 459
javascript onmouseclick

Hello,

This is continued from a question I asked http://cybertechhelp.com/forums/showthread.php?t=22796
but I htought it would be more use to people if I asked my next q in a separate thread.

I have created a simple web page. I want images called one and two to change when I have clicked on the image. HOwever it does not work. It would when I do onmousedown and onmouseup but not onmouseclick. Ithink it is summit to do with my href becuase it calls the page again and so loads up the original image.
THe code fo the page is:


<HTML>


<HEAD>


<SCRIPT>

Rollimage = new Array()
Rollimage[0] = new Image(250,175)
Rollimage[0].src = "images/one.jpg"
Rollimage[1] = new Image(250,175)
Rollimage[1].src = "images/two.jpg"


function Clicker(number){
if (number == 1)
{
document.IM1.src = Rollimage[1].src;
return true;
}

if (number == 2)
{
document.IM2.src = Rollimage[1].src;
return true;
}

}

</SCRIPT>
</HEAD>

<BODY>

<TABLE width="80%" align = center border=1>
<TR>
<TD><A onmousedown=Clicker(1) href="index.html">
<IMG src="images/one.jpg" border=0 name=IM1>
</A>
</TD>
</TR>

<TR>
<TD><A onmouseclick=Clicker(2)href="index.html">
<IMG src="images/one.jpg" border=0 name=IM2>
</A>
</TD>

</TR>
</TABLE>

</BODY>
</HTML>


It is a table with two rows. One to show onmousedown works. the next row is the onmouseclick adn this doesnt work!

Any ideas? Thanks

Richard
__________________
http://www.richardjones.info

Processor: Duron 1100
RAM: 256MB
OS: WinXP

Last edited by RichardJones; September 18th, 2003 at 02:58 PM.
Reply With Quote
  #2  
Old September 18th, 2003, 03:13 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,023
Blog Entries: 1
Is onclick not onmouseclick.
Also, remember to use quotes and in javascript start from zero not one.

Code:
<HTML>


<HEAD>


<SCRIPT>

Rollimage = new Array()
Rollimage[0] = new Image(250,175) 
Rollimage[0].src = "http://www.cybertechhelp.com/forums/images/newthread.gif" 
Rollimage[1] = new Image(250,175)
Rollimage[1].src = "http://www.cybertechhelp.com/forums/images/reply.gif" 


function Clicker(number){
if (number == 0)
{
document.IM1.src = Rollimage[1].src;
return true;
}

if (number == 1)
{
document.IM2.src = Rollimage[0].src;
return true;
}

}

</SCRIPT>
</HEAD>

<BODY>

<TABLE width="80%" align = center border=1>
<TR>
<TD><A onmousedown="Clicker(0)" href="#">
<IMG src="http://www.cybertechhelp.com/forums/images/newthread.gif" border="0" name="IM1">
</A> 
</TD>
</TR>

<TR>
<TD><A onclick="Clicker(1)" href="#">
<IMG src="http://www.cybertechhelp.com/forums/images/reply.gif" border="0" name="IM2">
</A> 
</TD>

</TR>
</TABLE>

</BODY>
</HTML>
__________________
Cheers,
Degs

Please post back with your results
CTH Terms of Use

CTH Subscriptions :: Adaware Guide :: HijackThis
Reply With Quote
  #3  
Old September 19th, 2003, 09:29 AM
RichardJones RichardJones is offline
Senior Member
 
Join Date: Dec 2000
O/S: Windows XP Pro
Location: Woking, Surrey, UK
Age: 28
Posts: 459
Thanks for your help degsy
__________________
http://www.richardjones.info

Processor: Duron 1100
RAM: 256MB
OS: WinXP
Reply With Quote
Reply

Bookmarks

Topic Tools

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 03:36 AM.

[ RSS ]