Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- var tipo_selected;
- changeTipo();
- changeProduto();
- });
- function changeTipo(){
- $("#tipo-produto").change(function(data){
- tipo_selected = data.target.selectedOptions[0].value;
- alterSelectProdutos(tipo_selected);
- });
- }
- function changeProduto(){
- $('#produto-manual').change(function(data){
- var produto_selected = data.target.selectedOptions[0].getAttribute("data-tipo");
- console.log(produto_selected, tipo_selected);
- if (produto_selected == tipo_selected) {
- $("#go").click(function () {
- console.log("Button event registered!");
- location.href = "https://google.com"
- });
- }
- });
- }
- function alterSelectProdutos(tipo_selected){
- $('#produto-manual options').hide();
- $('#produto-manual 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();
- }
- });
- $("#produto-manual option:first").prop('selectedIndex',0);
- }
Add Comment
Please, Sign In to add comment