-
February 28th, 2002, 04:55 PM
#1
[RESOLVED] Referencing table cells (td tags)
What I am trying to do is to have an image swap (change to another image) in one cell of the table when the mouse is OVER an image in another cell. I know that JavaScript would need to be used but I am only a beginner in JavaScript and I have no idea how to reference another cell.
Any help will be appreciated.
-
March 2nd, 2002, 09:55 AM
#2
I don't remember much of it but you can refer directly to the picture in question and skip the cell all together.
If you are into Video Editing : <a href="http://www.highvid.com" target="_blank">www.HighVid.com</a>
-
March 13th, 2002, 01:42 PM
#3
Registered User
Yeah as Scuba said you don't have to reference the cell, only the image
Try this (not in depth, just example)
put this in the head:
<script language="Javascript">
function changeImage(name){
docum ent[name].src = "/path/imagetoshow";
}
</script>
Image to swap:
<img src="/path/imagetoswap" name="toSwap">
Image to trigger the swap:
<img src="/path/imagetotrigger" onmouse0ver="changeImage('toSwap');">
note chage "0" in 0ver to "o"
also change all "src" location to valid image references
This is very basic.. if you want something more indepth, like the ability to switch the image back to the original when the user mouses out, let me know and I will send you a detailed script
Let me know if this helps
Spend One Hour of Every Day Like it was Your last, you'll Live much better that way
-
March 13th, 2002, 04:24 PM
#4
Registered User
Oh, btw, this is called a "Rollover image".
Also, here's some code that you could use so that you don't have to get all jiggy with javascript and stuff:
<a href="http://home.earthlink.net/~seanmorrison/testing.htm" target="_blank">Click here to see the code</a>
You can just replace the test marked in red with whatever images and links you want to use. And it's as simple as copying and pasting one line into your html code.
-
March 26th, 2002, 03:32 PM
#5
Registered User
[quote]Originally posted by WebHead:
<strong>Oh, btw, this is called a "Rollover image".
Also, here's some code that you could use so that you don't have to get all jiggy with javascript and stuff:
<a href="http://home.earthlink.net/~seanmorrison/testing.htm" target="_blank">Click here to see the code</a>
You can just replace the test marked in red with whatever images and links you want to use. And it's as simple as copying and pasting one line into your html code.</strong><hr></blockquote>
Hey how's it going WebHead
Actually this bit of code won't work:
<span style="color: #FF3333;"><a href="www.enteraurlhere.com" onMouse0ut="MM_swapImgRestore()" onMouse0ver="MM_swapImage('Image1','','/folder/firstimage.jpg',1)"><img name="Image1" border="0" src="/folder/secondimage.jpg" width="75" height="75"></a></span>
you see above, this code is generated from a Macromedia wysiwyg (i.e DreamWeaver) and you calling the functions "MM_swapImgRestore()" and ="MM_swapImage()" these function need to be put into a Javascript in the head of your page, if not you will get an object error.
Here is your test code modified to do what you were referencing (no javascript in head)
<span style="color: #0000FF;"><a href="www.enteraurlhere.com" onMouse0ut="document.Image1.src = 'old image path';" onMouse0ver="document.Image1.src = 'new image path';"><img name="Image1" border="0" src="current image path"></a></span>
this will work, just copy this to your page and add your image paths, anchor path, and change the zero's in the mouse action tags back to "O"
not flamming just helping
Spend One Hour of Every Day Like it was Your last, you'll Live much better that way
-
March 26th, 2002, 03:39 PM
#6
Registered User
Hmmm,.. true. I never noticed that before. My bad. Ooops.
-
March 27th, 2002, 01:53 PM
#7
but let's say that I want to referance a cell in a table.....
How actually do I do it ? <img src="confused.gif" border="0">
If you are into Video Editing : <a href="http://www.highvid.com" target="_blank">www.HighVid.com</a>
-
March 27th, 2002, 08:02 PM
#8
Registered User
-
March 28th, 2002, 03:34 PM
#9
What I was thinking is changing or more correct to say, setting the content of a table cell.
So To set the cell ID is not complicated, and I can understand how to change it's properties,
But how to I change the text that is in the cell ?
What do I put instead of the .className ?
If you are into Video Editing : <a href="http://www.highvid.com" target="_blank">www.HighVid.com</a>
-
April 2nd, 2002, 11:33 PM
#10
Registered User
[quote]Originally posted by Scuba:
<strong>What I was thinking is changing or more correct to say, setting the content of a table cell.
So To set the cell ID is not complicated, and I can understand how to change it's properties,
But how to I change the text that is in the cell ?
What do I put instead of the .className ?</strong><hr></blockquote>
well its really not that easy.. there is no way to directly change the contents of a cell (text that is) but you can simulate this
Example:
Put this in your document head:
<span style="color: #660000;">
<script language="Javascript">
Showing = "show1"; // Initially declare what is visible
notShowing = "show2"; // Initially declare what is hidden
function changeText(){
do cument.all[notShowing].style.visibility = "visible"; // Show the hidden layer
ho lder = Showing; // Temporarily hold the ID of the layer that was showing
do cument.all[Showing].style.visibility = "hidden"; // Hide the visible layer
Sh owing = notShowing; // Reset "Showing" to the layer that is now visible
no tShowing = holder; // Reset "notShowing" to the layer that is now hidden
}
</script>
</span>
Put this in your document body:
<span style="color: #000099;">
<table width="200">
<tr>
<td>
<span id="show1" style="position: absolute; visibility: visible;">Hello this is span id "show1"</span>
<span id="show2" style="position: relative; visibility: hidden;">Dude this is span id "show2"</span></td>
</tr>
<tr>
<td><a href="Javascript:changeText();">Click to change contents of "td"</a></td>
</tr>
</table>
</span>
Whats happening here is we are setting two span tags in the same datacell with different content in each, we are placing them over top of each other with css positioning, and hiding one of the span tags. With the javascript were changing the visibility of the span tags to simulate a content change.
Do I got it yet, or you still looking for something else
Spend One Hour of Every Day Like it was Your last, you'll Live much better that way
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|
Bookmarks