Solved

Javascript in php for select option to image

Posted on 2014-02-18
5
1,377 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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.

724 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