Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Boostrap dropdown on change

Posted on 2015-02-17
3
Medium Priority
?
141 Views
Last Modified: 2016-02-25
Hi I would like to achive a dropdown on change function to work with bootstrap dropdown .

on select of dropdown value i have show and hide content divs. each dropdown value i have different div to show.. it should not overlap each other i mean to say one time it should only show one div. remaining things needs to hidden. by defulat one value needs to selected that is xml and his content.

below is the code for the drop down

 <div class="btn-group" id="service_type">
                        <button type="button"  class="btn btn-default dropdown-toggle endPoint_type" data="xml" data-toggle="dropdown"> XML <span class="caret caret_right"></span></button>
                          <ul class="dropdown-menu endpoint-icons" role="menu" id="opdropdown">
                             <li role="presentation" class="dropdown-header">Technology Adapters</li>
                             <li class="xml"><a href="javascript:void(0)" > XML</a></li>
                             <li class="soap" id="soap"><a href="javascript:void(0)" > SOAP</a></li>
                             <li class="json"><a href="javascript:void(0)"> JSON</a></li>
                             <li class="java"><a id="java" href="javascript:void(0)"> Java</a></li>
                             <li role="presentation" class="dropdown-header">Business Adapters</li>
                             <li class="salesfor" id="salesforce"><a href="javascript:void(0)"> Salesforce</a></li>
                             <li class="sap"><a id="sap" href="javascript:void(0)">  SAP gateway</a></li>
                          </ul>
                      </div>

and attached image for your reference which im looking at to achieve . any one can help please
0
Comment
Question by:sastry_hora
[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
  • 2
3 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 2000 total points
ID: 40614929
jQuery:
$('.dropdown-menu li').on('click', function(){
		$('div.hiddenDiv').hide();
		var divClass = $(this).attr('class');
		$('div.' + divClass + ' p').text('This is the hidden div for the ' + divClass + ' dropdown selection.');
		$('div.' + divClass).show();
	});
	$('div.hiddenDiv button').on('click', function(){
		$('div.hiddenDiv').hide();
	});

Open in new window

HTML:
<div class="btn-group" id="service_type">
                        <button type="button"  class="btn btn-default dropdown-toggle endPoint_type" data="xml" data-toggle="dropdown"> XML <span class="caret caret_right"></span></button>
                          <ul class="dropdown-menu endpoint-icons" role="menu" id="opdropdown">
                             <li role="presentation" class="dropdown-header">Technology Adapters</li>
                             <li class="xml"><a href="javascript:void(0)" > XML</a></li>
                             <li class="soap" id="soap"><a href="javascript:void(0)" > SOAP</a></li>
                             <li class="json"><a href="javascript:void(0)"> JSON</a></li>
                             <li class="java"><a id="java" href="javascript:void(0)"> Java</a></li>
                             <li role="presentation" class="dropdown-header">Business Adapters</li>
                             <li class="salesfor" id="salesforce"><a href="javascript:void(0)"> Salesforce</a></li>
                             <li class="sap"><a id="sap" href="javascript:void(0)">  SAP gateway</a></li>
                          </ul>
                      </div>
        <div class="hiddenDiv xml"><button>X</button><p></p></div>
        <div class="hiddenDiv soap"><button>X</button><p></p></div>
        <div class="hiddenDiv json"><button>X</button><p></p></div>
        <div class="hiddenDiv java"><button>X</button><p></p></div>
        <div class="hiddenDiv salesfor"><button>X</button><p></p></div>
        <div class="hiddenDiv sap"><button>X</button><p></p></div>

Open in new window

As written, it will only work if each dropdown item has a single unique class name.
0
 

Author Closing Comment

by:sastry_hora
ID: 40614963
Exactly what i needed but at first load all div is showing up i added display none for each of them its working as expected.. thanks so much for quick help
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 40615102
Sorry, forgot to include my css for the hidden divs.

div.hiddenDiv {
            width:300px;
            height:200px;
            background-color:#def;
            display:none;
            position:absolute;
            top:300px;
            left:300px;
      }

Thanks for the points.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

598 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