javascript - If a Select All option is Checked then display a div using bootstrap multiselect -


after selecting "select all" option in drop down list,i'll click on generate graph button.then want display chart containing of options in drop down list in particular div using bootstrap multi-select.

my code:

<html xmlns="http://www.w3.org/1999/xhtml"> <head>   <title>jquery multi select dropdown checkboxes</title>   <link rel="stylesheet" href="css/bootstrap-3.1.1.min.css" type="text/css" />   <link rel="stylesheet" href="css/bootstrap-multiselect.css" type="text/css" />   <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>   <script type="text/javascript" src="js/bootstrap-2.3.2.min.js"></script>   <script type="text/javascript" src="js/bootstrap-multiselect.js"></script>   <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> </head> <body> <div id="pidiv"></div> <div id="alldiv"></div> <form id="form1">   <div style="padding:20px">     <label>select country</label>     <select id="selectid" multiple="multiple">       <option value="india">india</option>       <option value="japan">japan</option>       <option value="germany">germany</option>       <option value="nepal">nepal</option>       <option value="iraq">iraq</option>       <option value="china">china</option>     </select><br /><br />     <input type="button" id="btnget" value="get selected values" />     <script type="text/javascript">       $(function() {         $('#selectid').multiselect({           includeselectalloption: true         });         $('#btnget').click(function() {           alert($('#selectid').val());           if($('#selectid').val() == "india"){             $("#pidiv").load("/home/divya/html_docs/pi.html");           }         })       });     </script>   </div> </form> </body> </html> 

i'm able select 1 option , display corresponding chart.but select option,i'm not getting how display div after clicking on generate graph button.can please suggest me on issue ...

try option. change html below , replace url in data-url

<select id="selectid" multiple="multiple">     <option value="india" data-url="<!-- url -->">india</option>     <option value="japan" data-url="<!-- url -->">japan</option>     <option value="germany" data-url="<!-- url -->">germany</option>     <option value="nepal" data-url="<!-- url -->">nepal</option>     <option value="iraq" data-url="<!-- url -->">iraq</option>     <option value="china" data-url="<!-- url -->">china</option> </select> 

jquery code

$('#btnget').click(function() {     $("#pidiv").empty();     $('#selectid option:selected').each(function(index,elem){         if(typeof $(elem).data('url') != "undefined"){             $.get( $(elem).data('url'), function( data ) {                 $("#pidiv").append(data);             });         }     }); }) 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -