SW/assets/js/selectTicket.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-05-28 14:21:10 +02:00
/**
* Práctica - Sistemas Web | Grupo D
* CompluCine - FDI-cines
*/
2021-05-27 18:01:24 +02:00
// Método 1: recargar la página y enviar un GET.
window.onload = function(){
2021-06-01 09:52:53 +02:00
if(!select_cinema()) select_film();
}
function select_cinema(){
2021-05-27 18:01:24 +02:00
var select = document.getElementById("select_cinema");
2021-06-04 12:38:17 +02:00
2021-06-01 09:52:53 +02:00
if(select != undefined){
select.onchange = function(){
location.href += "&cinema=" + $('select[id=cinemas]').val();
}
return true;
} else {
return false;
2021-05-27 18:01:24 +02:00
}
}
2021-06-01 09:52:53 +02:00
function select_film(){
var select_ = document.getElementById("select_film");
select_.onchange = function(){
location.href += "&film=" + $('select[id=films]').val();
}
2021-05-31 12:05:22 +02:00
}
2021-06-01 09:52:53 +02:00
2021-05-28 14:21:10 +02:00
// Método 2: enviar una petición AJAX con POST. ==> (NO FUNCIONA, PERO LA IDEA ERA HACERLO ASÍ PARA EVITAR REFRESCAR LA PÁGINA Y LLENAR LA URL)
2021-05-27 18:01:24 +02:00
/*
$(document).ready(function(){
2021-05-31 12:05:22 +02:00
$("#select_cinema").change(function(){
2021-05-27 18:01:24 +02:00
var cinema = $('select[id=cinemas]').val();
//console.log($('select[id=cinemas]').val());
2021-05-31 12:05:22 +02:00
2021-05-27 18:01:24 +02:00
$.ajax({
2021-05-31 12:05:22 +02:00
url : "index.php",
type : "post",
dataType : "html",
data : "",
success: function(response){
$("#cinemas > option[value="+ cinema +"]").attr("selected", true);
2021-05-27 18:01:24 +02:00
console.log(cinema);
},
2021-05-31 12:05:22 +02:00
error: function(response){
2021-05-27 18:01:24 +02:00
console.log(response + ' ==> Error al seleccionar el cine')
}
});
});
});
*/