473,657 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(simple?) DOM problem

I have a simple DHTML gallery:

<script>
viewPhoto(thumb ){
function viewPhoto(thumb ){
document.getEle mentById('mainP hoto').src=thum b.href;
return false;
}
</script>

....
<body>
<a onclick="javasc ript:return viewPhoto(this) ;" href="whatever" ><img src="thumbnail" /></a>
</body>
....
I want the currently viewed images' thumbnail to have a nice thick red-border.
I have managed to do this slap dash, but I had a better way, My only problem is
that I need to find out the DOM Array value of the thumbnail object (ie the "thumb" param)
Is this possible?
Feb 8 '06 #1
4 1325
bmgz said the following on 2/8/2006 6:16 AM:
I have a simple DHTML gallery:
No, that's not a "DHTML gallery", it is a simple image swap routine.
<script>
<script type="text/javascript">
viewPhoto(thumb ){
That is a good example of why people shouldn't try to type/paste
snippets into a post. I have to assume that was an errant mis snip.

function viewPhoto(thumb ){
document.getEle mentById('mainP hoto').src=thum b.href;
document.images['imageNAME'].src = thumb.href;

Now, it is more cross-browser friendly.
return false;
}
</script>

....
<body>
<a onclick="javasc ript:return viewPhoto(this) ;" href="whatever" ><img
no need for the javascript: label, drop it.
src="thumbnail" /></a>
</body>
....
I want the currently viewed images' thumbnail to have a nice thick
red-border.
Then give it one. That is what CSS is for:

<img ...... name="mainPhoto " style="border: solid 20EM red">

How thick do you want it?
I have managed to do this slap dash, but I had a better way
What in the world is a "slap dash"?
My only problem is that I need to find out the DOM Array value of
the thumbnail object (ie the "thumb" param)
Nothing in that sentence makes any sense at all.

What is a "DOM Array value"?
Is this possible?


Nobody can answer that until you explain what it is you are trying to do.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 8 '06 #2
I tried to simplify the the code, but I ended up making a hash of things,
It is DHTML because I brought CSS into the mix (not visible in my pityful earlier post)
I can code but my jargon sux like **** (I don't converse verbally with other coders..)
anyways here goes:

function viewPhoto(thumb ){
document.getEle mentById('mainP hoto').src=thum b.href;
thumbs = document.getEle mentById('prope rty-thumbnail-browser').getEl ementsByTagName ('img');
for(i=0; i<thumbs.length ; i++){
thumbs[i].className="thu mbnail-normal";
}
thumb.firstChil d.className="th umbnail-current";
return false;
}

I want to neaten this code by changing the loop logic to:

function viewPhoto(thumb ){
document.getEle mentById('mainP hoto').src=thum b.href;
thumbs = document.getEle mentById('prope rty-thumbnail-browser').getEl ementsByTagName ('img');
for(i=0; i<thumbs.length ; i++){
< If this is the image i clicked on > <-- I need to find the Index of the object???
thumb.firstChil d.className="th umbnail-current";
< Else >
thumbs[i].className="thu mbnail-normal";
}

return false;
}

I know this looks crude because the firstChild etc. relies implicitly on my markup being precise,
but it works for me... Another wierd thing I noticed was Firefox treating a literal space ' ' in
your markup as a Node?
Feb 8 '06 #3
bmgz wrote:
I can code but my jargon sux like **** (I don't converse verbally with
other coders..)


converse? sorry it's been a long day ;(
Feb 8 '06 #4
bmgz wrote on 08 feb 2006 in comp.lang.javas cript:
function viewPhoto(thumb ){
document.getEle mentById('mainP hoto').src=thum b.href;
thumbs =
document.getEle mentById('prope rty-thumbnail-browser').getEl ementsB
yTagName('img') ; for(i=0; i<thumbs.length ; i++){
< If this is the image i clicked on > <-- I need to find the
Index of the object???
thumb.firstChil d.className="th umbnail-current";
< Else >
thumbs[i].className="thu mbnail-normal";
}

return false;
}


var which = false;

function viewPhoto(thumb ){
document.getEle mentById('mainP hoto').src = thumb.src;
if (which)
which.firstChil d.className = "thumbnail-normal";
thumb.firstChil d.className="th umbnail-current";
which = thumb;
return false;
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 8 '06 #5

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

Similar topics

3
3684
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example program #include <list>
6
2142
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. could you please have a look at the following script: ------------------------------------------------------------
0
1880
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I have run into is that the emitted html at the end of the process is slightly different and doesn't work. Please don't be put off by all the source code. All the guts are in this first base class, and it doesn't do much. The rest is trivial...
18
1502
by: Sender | last post by:
Yesterday there was a very long thread on this query. (You can search on this by post by 'sender' with subject 'Simple Problem' post date Oct 7 time 1:43p) And in the end the following code was decided to open a new form: ---Code in the click event of a button: button1 if frm is nothing then frm = new form2() frm.show
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.