Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

noob question- popdown image change

Status
Not open for further replies.

Zas

Programmer
Oct 4, 2002
211
US
I was wondering if there was a way where a user could have a drop down menu to select an image from a forum, and once they select one the image pops up so they can look at it, and possibly change the image, where another one would pop up once they change it again, etc..
Possible? If so, how?

Happieness is like peeing your pants.
Everyone can see it, but only you can feel the warmth.
 
Hi Zas,

You could try something simple like this:

Have your thumbnails as <img> with a A HREF around them:

<a href=&quot;#&quot; onClick=&quot;card.src='/images/ecards/BigImage.jpg';&quot;>

And your main image called &quot;card&quot; (in this example)

<img src=&quot;/images/ecards/blank.jpg&quot; name=&quot;card&quot; width=&quot;496&quot; height=&quot;234&quot; border=&quot;0&quot;>

You just feed the card.src of whichever big image you want displayed.

Its a simple way, maybe someone has something better? :)

Cheers
BatGrrrL
 
And this is the code to do it with a drop down box :) Note: the three images I used were in the same directory as my script.

<html><head>

<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
<!--
function image_go()
{

selecteditem = myForm.myImages.selectedIndex ;
myImg = myForm.myImages.options[ selecteditem ].value ;
if (myImg.length != 0) {
card.src = myImg ;
}
}
//-->
</script>

</head><body>
<form name=&quot;myForm&quot;>

<select name=&quot;myImages&quot; onChange=&quot;image_go();&quot;>
<option value=&quot;amy.gif&quot;>First</option>
<option value=&quot;one.gif&quot;>Second</option>
<option value=&quot;ralph.gif&quot;>Third</option>
</select>

</form>


<img src=&quot;amy.gif&quot; name=&quot;card&quot; width=&quot;496&quot; height=&quot;234&quot; border=&quot;0&quot;>
</body>
</html>
 
weeee tanks u

Happieness is like peeing your pants.
Everyone can see it, but only you can feel the warmth.
 
Here's a way to dynamically generate a window and resize it to the pic size.

var str = &quot; &quot;;
var w;
var topPos = 0;
var leftPos = 0;
var wt = 0;
var ht = 0;
var picName = &quot;&quot;;

function getPic(pn, m, n)
{
if(screen)
{
leftPos = (screen.width - m)/2;
topPos = (screen.height - n)/2;
wt = m;
ht = n;
}
picName = pn;
w = window.open(&quot;&quot;,&quot;&quot;,&quot;toolbars=no,scrollbars=no,resizable=no,directories=no,location=no,left=&quot;+leftPos+&quot;,top=&quot;+topPos+&quot;,width=&quot;+wt+&quot;,height=&quot;+ht);
str = &quot;<body marginwidth='0' marginheight='0' topmargin='0' leftmargin='0'>&quot;;
str += &quot;<a href = \&quot;javascript:self.close()\&quot;><img src = &quot;;
str += picName.toString();
str += &quot; border = '0'><\/a>&quot;;
str += &quot;<\/body>&quot;;
writeWin();
}

function writeWin()
{
if(w && w.open)
{
w.focus();
w.document.open();
w.document.write(str);
w.document.close();
}
else
{
writeWin();
}
}

and for the link put-

<a href=&quot;#&quot; onclick=&quot;getPic('images/myPic.jpg',320,427);return false&quot;>

~mgb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top