473,563 Members | 2,895 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 1322
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
3669
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
2137
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
1874
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...
18
1494
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
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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...
0
8106
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...
0
7950
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...
0
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
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
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
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...

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.