By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

how to show and hidden when dropdown selected value change?

P: 1
I'm using codeigniter to create my php web site in my view page I need to set visible when the drop-down value change how can i do that?
this the button that i need visible and hidden when drop-down change

dropdown
Expand|Select|Wrap|Line Numbers
  1.  <div class="form-group">
  2.          <label for="lastname" class="control-label">Your Packages</label>
  3.            <?php if(isset($tourbuddy_packages)){?>
  4.               <select id="itemType_id" class="form-control input-sm" name="tripbuddy_PackageTitle" >
  5.            <?php
  6.                 foreach ($tourbuddy_packages as $packages) {?>
  7.                    <option value="<?php echo $packages['PackageID'] ?> "><?php echo $packages['PackageTitle']?></option>
  8.             <?php } ?>
  9.             </select>
  10.             <input type="hidden" name="PackageID" id="country_hidden">
  11.              <?php }  else { ?>
  12.                 <select class="form-control input-sm" name="tripbuddy_PackageTitle">
  13.                     <option>Add Packages</option>
  14.                   </select>
  15.               <?php } ?>
  16. </div>
button
Expand|Select|Wrap|Line Numbers
  1. <button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#yourpackages" >View/Edit</button>
other than this i used some javascrip to send ajax request to my controller
Expand|Select|Wrap|Line Numbers
  1. $("#itemType_id").change(function() {
  2.  
  3.  
  4.             $.ajax({
  5.                 url : "feature/tea/",
  6.                 method: "post",
  7.                 data: "id=" + $(this).val(),
  8.                 dataType:"json",
  9.                 success: function(response) {
  10.                    window.location.reload();
  11.  
  12.                     // handle
  13.                 }
  14.             })  
  15.         });
Mar 31 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.