Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Closed Thread
 
LinkBack Thread Tools
Old October 2nd, 2007, 03:49 PM   #1
Reputable Member
 

Join Date: May 2007
Location: Margate
Age: 26
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 R8515198 is on a distinguished road
[SOLVED] Changing pictures on same page

Good evening,

how do i go about changing a picture on a page without the page having to reload.

For example, you have a shirt, same design 5 different colours, you want to display 1 on the page but have a button on the page that changes the colour. Not to select a colour just to move to the next colour.

Any help will be greatful

Cheers

Dan
R8515198 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 03:53 PM   #2
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: Changing pictures on same page

this would require JavaScript. I'm sure someone can recommend a script.
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 04:39 PM   #3
Elite Veteran
SuperMember
 
welshstew's Avatar
 

Join Date: May 2007
Location: inside the outside
Posts: 3,909
Blog Entries: 14
Thanks: 9
Thanked 40 Times in 38 Posts
Rep Altering Power: 0 welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute
Re: Changing pictures on same page

ok, this should work

put this in your head section

Code:
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
then in your html you need the following to identify the main image (before the rollover swap)
Code:
<img width="350" height="350" id="thisimagename" name="thisimagename" src="/images/image1.gif"/>
changing the id and name to whatever you want.

then for each link option (green, red, etc) you need the following
Code:
<a onmouseover="MM_swapImage('thisimagename','','/images/image1red.gif',1)" href="javascript:;"><img width="15" height="15" border="0" src="/images/image1red_icon.gif"/> RED </a>
the blue indicates the image you want to swap it to.

let me know if that helps, and post a link once you have implemented it so that we can have a look.

Stew
__________________
WelshStew
extreme sports clothing and t-shirts | twitter| web design

Last edited by karinne; October 2nd, 2007 at 05:19 PM.. Reason: just checking something.
welshstew is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 05:12 PM   #4
Reputable Member
 

Join Date: May 2007
Location: Margate
Age: 26
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 R8515198 is on a distinguished road
Re: Changing pictures on same page

Cheers for the info so quick have tested it (its great), might be able to post a link tonight if i finsh it.

Cheers
Dan
R8515198 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 05:21 PM   #5
Elite Veteran
SuperMember
 
welshstew's Avatar
 

Join Date: May 2007
Location: inside the outside
Posts: 3,909
Blog Entries: 14
Thanks: 9
Thanked 40 Times in 38 Posts
Rep Altering Power: 0 welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute
Re: Changing pictures on same page

cool, would be interested to see how you implement this.
__________________
WelshStew
extreme sports clothing and t-shirts | twitter| web design
welshstew is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 05:45 PM   #6
Elite Veteran
SuperMember
 
welshstew's Avatar
 

Join Date: May 2007
Location: inside the outside
Posts: 3,909
Blog Entries: 14
Thanks: 9
Thanked 40 Times in 38 Posts
Rep Altering Power: 0 welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute welshstew has a reputation beyond repute
Re: Changing pictures on same page

just looking to buy some new threads when I came across meatandcheese who are doing the same thing but in a slightly different way. you can just *borrow* their code if you want

Stew
__________________
WelshStew
extreme sports clothing and t-shirts | twitter| web design
welshstew is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 07:57 PM   #7
Reputable Member
 

Join Date: May 2007
Location: Margate
Age: 26
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 R8515198 is on a distinguished road
Re: Changing pictures on same page

Done it,

Cheers for the assitance, have a look around the website if you wish still underconstruction. Its just a personal one.


http://hondavfrnc30.friendsworld.co....ons/index.html

thanks again

Dan
R8515198 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old October 2nd, 2007, 08:14 PM   #8
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: Changing pictures on same page

looks great
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CSS changing page colour etc R8515198 HTML, XHTML and CSS 10 November 26th, 2007 08:54 PM
Ive A Php Page I Need Help With My Pictures Dont Appear Were They Should jingles PHP 3 September 24th, 2006 05:43 AM
Changing URL without refreshing page ? Perfection Studios JavaScript 4 September 14th, 2006 08:22 AM
Changing css with page refresh krrish HTML, XHTML and CSS 3 July 26th, 2006 04:20 AM


Search Engine Optimization by vBSEO 3.2.0 RC8