Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Rollover using Dropdown Box help



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
Randor



Joined: 25 Apr 2008
Posts: 1

PostPosted: Fri Apr 25, 2008 4:52 pm    Post subject: Rollover using Dropdown Box help Reply with quote

ok, i am trying to do a simple dropdown box that when a user clicks on one of the items and image rollover happens and they can see the object they are selecting, however i am not real good in JS and i tried to modify an existing code and i think i completly screwed it up...

I need the dropdown box to look something like this:

Code:
<select size="7" name="btl" >
    <option value="111">1</option>
    <option value="112">2</option>
    <option value="113">3</option>
    <option value="114">4</option>


this is so that when they click submit, the value is just this number, now, the images are saved in a seperate location named 111.gif, 112.gif, etc...

i tried adding this:
Code:
OnClick=document.arrow.src=this.options[this.selectedIndex].value;


but all it did was change the src in the image to 111 or 112, etc...

how can i get it to change the src in the image to something along these lines:

http://www.mysite.com/images/111.gif and
http://www.mysite.com/images/112.gif accordingly??

any help is appreciated...
Back to top
View user's profile Send private message
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 630
Location: Cebu City Philippines

PostPosted: Sat Apr 26, 2008 2:07 am    Post subject: Re: Rollover using Dropdown Box help Reply with quote

Don't use onclick, better of the onchange property Wink

...Give your select tag an id...for instance select and an onchange attribute to call for the function Smile

<select id="select" onchange="change()">

....Also, give your image an id of (for instance) myimage Wink

..Then try this script Smile
Code:

<script type="text/javascript">
function change()
{
   switch (document.getElementById("select").value)
   {
      case "111":
      document.getElementById("myimage").src='images/111.gif'
      break;
      case "112":
      document.getElementById("myimage").src='images/112.gif'
      break;
      case "113":
      document.getElementById("myimage").src='images/113.gif'
      break;
     case "114":
      document.getElementById("myimage").src='images/114.gif'
      break;
   }
}
</script>
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap