Reply
image rollover
Old 08-19-2004, 09:01 AM image rollover
Novice Talker

Posts: 5
Hi, i'm new here.. just wanted to ask a quick question...

I've tried about 2 forms of javascript and 1 form of css to try this...

On my forum I want to have the images roll over, BUT... the thing is, when you refer to the same instance of the image, it'll cancel everything out... As in a forum, how it'll have a button that shows "PM" on it for private message. Well in the tpl file you just setup the basic layout and it'll repeat for every reply. So anyways, is there a way to use the same 2 images (one as mouseout and mouseover) repeatedly throughout the same page? I can't understand how to make it work...
Demalii is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-19-2004, 09:14 AM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
With different text on? Thats a background rollover. Heres a quick example;

HTML Code:
<p style="background-image:URL('pic1.jpg');" id="rollOver1" onmouseover='rollOver1.style.backgroundImage="URL(\'pic2.jpg\');";' onmouseout='rollOver1.style.backgroundImage="URL(\'pic1.jpg\');";'>Test</p>
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources, http://www.webworrks.com
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-20-2004, 06:36 AM
Novice Talker

Posts: 5
ok now say that's in a tpl form, so.. like the database would read that tpl file and say, this is the layout for each post "name, post, button", if there's 15 posts all on the same page, it's going to load that code that you posted 15 times.. will that work using the same 2 images?
Demalii is offline
Reply With Quote
View Public Profile
 
Old 08-20-2004, 06:53 AM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
yes. But to be more efficient, you may want a function.

HTML Code:
<script language="Javascript">
function rollOverMe(object_id) {
     if(document.getElementById) {
            document.getElementById(object_id).style.backgroundImage="URL('pic2')";
    } else if(document.all) {
            document.all[object_id].style.backgroundImage="URL('pic2')";
    }
     return;
}

function rollOffMe(object_id) {
      if(document.getElementById) {
            document.getElementById(object_id).style.backgroundImage="URL('pic1')";
    } else if(document.all) {
            document.all[object_id].style.backgroundImage="URL('pic1')";
    }
     return;
}
</script>
<p style="background-image:URL('pic1.jpg');" id="rollOver1" onmouseover='rollOverMe("rollOver1");' onmouseout='rollOffMe("rollOver1");'>Test</p>

<p style="background-image:URL('pic1.jpg');" id="rollOver2" onmouseover='rollOverMe("rollOver2");' onmouseout='rollOffMe("rollOver2");'>Test</p>

<p style="background-image:URL('pic1.jpg');" id="rollOver3" onmouseover='rollOverMe("rollOver3");' onmouseout='rollOffMe("rollOver3");'>Test</p>
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources, http://www.webworrks.com
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-20-2004, 04:18 PM
Rufo's Avatar
Extreme Talker

Posts: 173
Quote:
Originally Posted by webwoRRks
<p style="background-image:URL('pic1.jpg');" id="rollOver1" onmouseover='rollOverMe("rollOver1");' onmouseout='rollOffMe("rollOver1");'>Test</p>

<p style="background-image:URL('pic1.jpg');" id="rollOver2" onmouseover='rollOverMe("rollOver2");' onmouseout='rollOffMe("rollOver2");'>Test</p>

<p style="background-image:URL('pic1.jpg');" id="rollOver3" onmouseover='rollOverMe("rollOver3");' onmouseout='rollOffMe("rollOver3");'>Test</p>
The code for each rollover couldn't be made unique as it is generated by the forum script, not by hand. You'd probably have to do something involving the 'this' object, so javascript knows which image you mean without using IDs.

Rufo.
__________________
mp3blog.us
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 08-20-2004, 06:03 PM
Novice Talker

Posts: 5
thanks for the help the two of you.. i'll try and figure this one out.
Demalii is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to image rollover
 

Thread 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14610 seconds with 12 queries