Click to See Complete Forum and Search --> : Multiple Events of Same Method?


Z3R0
09-14-2005, 01:06 PM
I just recently starting getting in depth with HTML, JAVA, and JS, I guess you can say so-so, but as anyone starting out... it's question time!!!
1) I've managed easily to get form style buttons to do image swapping... Not too hard, but is there anyway to do multiple onMouseOver's or onClicks to change various items?
2) Again with the image swapping, I found it pretty easy to do this with form style buttons, but items with an <A HREF> tag... exactly how is this setup? Like a regular link or an image button? I found a DECENT way to just create an anchor, and then do the onClick event, but is there anyway so that it doesn't refresh or have to have a target? Again, I'm working around in HTML and JS mainly atm, so if this easily in JS or something, feedback would be much appreciated. Thank you.

muneepenee
09-14-2005, 01:31 PM
1. the klik or onmouseover kan kall a funkshun. Funk kan hav 1000's av lines av kode & kan kall more funks.
2. 1 wae tu yuze anker...
<a href="javascript:window.print()">print this paej </a>
or
<a href="#" onClick="zoompik('but1')">klik tu make pik bigger</a>

Z3R0
09-14-2005, 01:42 PM
The current way I have been able to do the image swapping, isn't within JS, but within HTML, can HTML be formulated with functions?

is this correct? <A HREF="javascript:window.print()" onClick="document.whatever.src='new image.xxx'">Click Here to Change</A>

Fang
09-14-2005, 01:49 PM
The href attribute value should be an URL. JavaScript goes in the event handler, onclick.

muneepenee
09-14-2005, 02:03 PM
1. html is statik...kant muve or chaenj...that meen it kant flip piks.

Z3R0
09-14-2005, 03:20 PM
So then I'm lost... how can you create a regular link using <A HREF> to swap an image? I've been able to do it easiy with Form Button, and I even cheated with hidden anchors for regular <A HREF> Links to not reload the page, so what else can I do?

Fang
09-14-2005, 03:38 PM
What are you tring to achieve? Image swapping by clicking a link or an image? Image swapping can be do with css.

Z3R0
09-14-2005, 03:45 PM
ok say I have a single image + other crap on the page... I've been able to swap JUST the image with form styled buttons, using the onClick="document.NAME.src='newimageurl'" tag within the form's code... however, when I've tried doing this with standard links or image links... they need a target URL... is there anyway to set that target url so that it doesn't REFRESH the page? so far, the only way I've been able to do that, is with anchor's, but I know there's another way...

Fang
09-14-2005, 04:26 PM
This probably what you are looking for; as long as JavaScript is enabled the anchor will not direct you to the url.
<a href="http://www.mysite.com" onclick="alert('Hi there'); return false;">no refresh</a>
The return false prevents any further action.

Z3R0
09-15-2005, 12:11 AM
Does that go within a <SCRIPT> tag or just simply HTML?

Kravvitz
09-15-2005, 12:32 AM
No, that last piece of code does not go in a <script> element.

Image Switching with CSS (http://www.dynamicsitesolutions.com/css/background_image_switching/)

Z3R0
09-15-2005, 12:11 PM
*** EDITTED ***
Yes, That works perfectly for what I wanted... Thank you... Lastly, is there any way to perform multiple image swapping for different image labels using a single link?

Kravvitz
09-15-2005, 04:01 PM
You're welcome :)

Yes. Just add another statement to the event handler.

Z3R0
09-15-2005, 04:28 PM
hmmmm... I've tried using 2 onClick's on the same <A HREF> tag, but it got pissed off and didn't do anything...

EDITTED...
NEVERMIND, didn't even think about doing the same thing you all did with the return false... same " "'s, just separated by ;'s... thanks for the help.

Kravvitz
09-15-2005, 04:32 PM
Perhaps you forgot the semicolons. Please show us what you tried that didn't work.

Z3R0
09-15-2005, 04:32 PM
Yes, just figured it out, lawl my bad

Kravvitz
09-15-2005, 04:43 PM
Ok. I'm glad you figured it out.

You're welcome :)