473,699 Members | 2,811 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 1330
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
3692
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
2154
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
1888
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
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9055
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
8947
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,...
0
8902
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5891
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
4392
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...
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.