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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a image be modified by a select field?

Status
Not open for further replies.

grimbys

Programmer
Dec 19, 2002
34
ES
Hi! I have a image and a select field:

<body>

<p><img border=&quot;0&quot; src=&quot;1.jpg&quot; width=&quot;148&quot; height=&quot;180&quot;></p>
<form name=&quot;form1&quot;>
<p><select size=&quot;1&quot; name=&quot;foto_selec&quot;>
<option selected value=&quot;1&quot;>first</option>
<option value=&quot;2&quot;>second</option>
<option value=&quot;3&quot;>third</option>
</select></p>
</form>
<p> </p>

</body>
I want thath when I select second option the image change to 2.jpg and so.
How can I link the image with the selected option ?
After I read a tutorial about javascript, I think I can't do it, but I'm not sure.
Thanks. And Sorry for my bad english.
 
This should do it:

<body>

<p><img border=&quot;0&quot; src=&quot;1.jpg&quot; width=&quot;148&quot; height=&quot;180&quot; id=&quot;imgImgSelect&quot;></p>
<form name=&quot;form1&quot;>
<p><select size=&quot;1&quot; name=&quot;foto_selec&quot; onchange=&quot;document.getElementById('imgImgSelect').src= this.value + '.jpg'&quot;>
<option selected value=&quot;1&quot;>first</option>
<option value=&quot;2&quot;>second</option>
<option value=&quot;3&quot;>third</option>
</select></p>
</form>
<p> </p>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top