• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DropDown With Onchange Event

#1
I want to ask about if i want make dropdown with onchange event, so basically for every diferent option in dropdown value it will show diferent data, anyone can help me with the basic code?
Reply

#2
Simple Bootstrap Code:

<div class="container-fluid">
<div class="row">
<div class="col-md-offset-4 col-md-4 text-center">
<div class="form-group" style="margin-top: 50px;">
<label for="group">Dropdown List</label>
<select id="list" onchange="changeValue()" class="form-control">
<option value="0">Select Item</option>
<option value="1">Item One</option>
<option value="2">Item Two</option>
<option value="3">Item Three</option>
<option value="4">Item Four</option>
<option value="5">Item Five</option>
</select>
</div>
</div>
</div>
</div>

<script>
function changeValue() {
var value = $("#list").val();
alert(value);
}
</script>


Here I have created a git repo for you:

https://github.com/shahnewaz24557/ci-sim...n-onchange
Smile
Reply

#3
(05-07-2018, 06:49 PM)shurimano Wrote: I want to ask about if i want make dropdown with onchange event, so basically for every diferent option in dropdown value it will show diferent data, anyone can help me with the basic code?

Hi here is a simple implementation in jQuery

PHP Code:
<script>
 $(
"#dropdownUL").change(function () {

var 
valueSelected = $("#dropdownUL :selected").val();

// Do something

switch (valueSelected) {
 
   case "new":
 
       $('#newDiv').addClass('show');
 
       break;
 
   case 'new2':
 
        $('#newDiv2').addClass('show');
 
       break;
}


});
</script> 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.