?
Solved

Boostrap dropdown on change

Posted on 2015-02-17
3
Medium Priority
?
140 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

762 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