Computing.Net > Forums > Programming > Javascript query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Javascript query

Reply to Message Icon

Name: ian_ok
Date: January 28, 2006 at 09:38:29 Pacific
OS: win xp 98 & 2k
CPU/Ram: p3 512
Comment:

I'm using the following code on a list of images, when you click an image the large image changes. What I'd like is the user to be moved back to the top of the page to view the large image.

CODE:
<SCRIPT Language="JAVASCRIPT"> function imgchange(name){if(document.images){document.main.src = "images/photos/" + name; } else { document.main.src = "images/nophoto.gif"; }}</SCRIPT>

Layout like this:
BIG IMAGE HERE

small image 1
small image 2
small image 3
small image 4
small image 5
small image 6
small image 7
etc

So if you click on small image 7 the image schanges and you are moved back to the top of the page to view it.

I also pull in this function from another file:

echo "< a hre f=\"javascript:imgchange('$file_name')\"> ";
ec ho "<im g sr c=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\" alt=\"$thumb_file_name\">
";


Thanks Ian


Venta Sanlucar Sales



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: January 28, 2006 at 10:42:06 Pacific
Reply:

I would put an anchor around the large image like so:

< a name="largeiamge" > LARGEIMAGE < /a >

Then change the links for the small images to this:

echo "< a href=\"#largeiamge\" onclick=\"javascript:imgchange('$file_name')\"> ";
echo "< img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\" alt=\"$thumb_file_name\" >";

Then when you click that link the javascript will run, but the anchor link will also force the page to the top.


Michael J


0

Response Number 2
Name: ian_ok
Date: January 28, 2006 at 12:33:59 Pacific
Reply:

That works a treat Micheal, thanks.

I didn't know how to get round adding two commands to the href.

Ian

Venta Sanlucar Sales


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


php mysql alphabetized an... edit multiple htm files a...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Javascript query

javascript value for PHP variable www.computing.net/answers/programming/javascript-value-for-php-variable/4066.html

javascript for stock price? www.computing.net/answers/programming/javascript-for-stock-price/6893.html

SQL Queries in MS Access www.computing.net/answers/programming/sql-queries-in-ms-access/6911.html