Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- changeTipo();
- changeProduto();
- });
- function changeTipo(){
- $("#selectA").change(function(){
- var tipo_selected = $( "#selectA option:selected" ).text();
- alterSelectProdutos(tipo_selected);
- });
- }
- function changeProduto(){
- $('#selectB').change(function(data){
- var produto_selected = $( "#selectB option:selected" ).text();
- });
- }
- function alterSelectProdutos(tipo_selected){
- $('#selectB options').hide();
- $('#selectB option').each(function(index, data){
- console.log(this);
- console.log('Option:'+$(this).attr('data-tipo')+' selected:'+ tipo_selected);
- if($(this).attr('data-tipo') == tipo_selected){
- $(this).show();
- }else{
- $(this).hide();
- }
- });
- $("#selectB option:first").prop('selectedIndex',0);
- }
Add Comment
Please, Sign In to add comment