Solved

Javascript in php for select option to image

Posted on 2014-02-18
5
1,339 Views
Last Modified: 2014-03-03
Hi,

I have a dropdown , each value has a product image related to it.

So now i dont want the dropdown , and i want to show images corresponding to it.

So 3 dropdown values before, now i need 3 images display in a row instead of dropdown but use the same function as dropdown.

http://jsfiddle.net/32Tw4/

Thanks
0
Comment
Question by:magento
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:cstsang
ID: 39866819
You need to download the js lib. from the following web site:
http://www.marghoobsuleman.com/jquery-image-dropdown

There are a small tutorial show you how to use the js lib. in your script.

Good Luck
0
 
LVL 5

Author Comment

by:magento
ID: 39869429
Hi ,

Thanks for your advice, looks like it allows the image in the dropdown itself.

But is it possible to remove the dropdown and only shows images instead of it?

Thanks
0
 
LVL 7

Expert Comment

by:cstsang
ID: 39869647
0
 
LVL 7

Accepted Solution

by:
cstsang earned 500 total points
ID: 39869685
Is it what you need?
<html>
    <head>
         <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
         <script type="text/javascript" src="http://dl.dropboxusercontent.com/u/40036711/Scripts/jquery.ddslick.min.js"></script>
         <script language=javascript>
                //Dropdown plugin data
                var ddData = [
                    {
                        text: "Facebook",
                        value: 1,
                        selected: false,
                        description: "Description with Facebook",
                        imageSrc: "http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
                    },
                    {
                        text: "Twitter",
                        value: 2,
                        selected: false,
                        description: "Description with Twitter",
                        imageSrc: "http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
                    },
                    {
                        text: "LinkedIn",
                        value: 3,
                        selected: false,
                        description: "Description with LinkedIn",
                        imageSrc: "http://dl.dropbox.com/u/40036711/Images/linkedin-icon-32.png"
                    },
                    {
                        text: "Foursquare",
                        value: 4,
                        selected: false,
                        description: "Description with Foursquare",
                        imageSrc: "http://dl.dropbox.com/u/40036711/Images/foursquare-icon-32.png"
                    }
                ];            
                function start()
                {
                  $('#myDropdown').ddslick({
    data:ddData,
    width:400,
    selectText: "Select your preferred social network",
    imagePosition:"right",
    onSelected: function(returnDataObject){
        //callback function: do something with selectedData;
        alert(returnDataObject.selectedData.value);
    }   
});
                  
                }
         </script>
     </head>
     <body onload="start()">   
      <div id="myDropdown"></div>
     </body>
</html>  

Open in new window

0
 
LVL 5

Author Closing Comment

by:magento
ID: 39901119
Thank you ,
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question