View Single Post
  #2 (permalink)  
Old 05-07-2008, 08:45 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,560
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default Re: Change image url with dropdown selection

So right now when a user clicks on option 2 your ShowPic() function is executed. Which then assigns the value of the selection to a variable and changes the ShowRoom picture. The problem is the value is 2. So

>> Clicks 2
ShowPic(2);
document.ShowRoom.src = 2
URL of picture = 2.

Basically you just need to append the "images/variableXX.jpg" to the src. Here is how:

Code:
<script language="javascript">
<!--
function ShowPic(sImage)
{
   document.ShowRoom.src = "images/variable" + sImage + ".jpg";
}
// -->
</script>
An easier option would be to just change the value of your select. For Example:


Code:
<option value="images/variable1.jpg">Option 1</option>
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Reply With Quote