$('#select-meal-type option:selected').each(function() {
alert($(this).val());
});
lunes, 26 de septiembre de 2016
Elementos seleccionados de un select multiple Javascript
miércoles, 21 de septiembre de 2016
Seleccionar automaticamente elementos Select Javascript
functionselectInCombo(combo,val){for(varindice=0 ;indice{if(document.getElementById(combo).options[indice].text==val )document.getElementById(combo).selectedIndex =indice;}}
Escuchar antes de evento submit Javacript
$('#formTest').submit(function(ev) {
ev.preventDefault(); // to stop the form from submitting
/* Validations go here */
var count = $("#usuarios :selected").length;
alert(count);
this.submit(); // If all the validations succeeded
});
ev.preventDefault(); // to stop the form from submitting
/* Validations go here */
var count = $("#usuarios :selected").length;
alert(count);
this.submit(); // If all the validations succeeded
});
Elementos selecionados de un Select multiple Javascript
var count = $("#mySelect :selected").length;
lunes, 12 de septiembre de 2016
Parsear Json Javascript
var jsonData = JSON.parse(myMessage);
for (var i = 0; i < jsonData.counters.length; i++) {
var counter = jsonData.counters[i];
console.log(counter.counter_name);
}
jueves, 1 de septiembre de 2016
Diferencia de fechas PHP
$fecha="2012-02-14 00:00:00";$segundos=strtotime($fecha) - strtotime('now');$diferencia_dias=intval($segundos/60/60/24);echo "La cantidad de días entre el ".$fecha." y hoy es ".$diferencia_dias.";
Convertir segundos a dias, horas, minutos y segundos PHP
function seg_a_dhms($seg) {
$d = floor($seg / 86400);
$h = floor(($seg - ($d * 86400)) / 3600);
$m = floor(($seg - ($d * 86400) - ($h * 3600)) / 60);
$s = $seg % 60;
return "Dias: $d, horas: $h, minutos: $m, segundos: $s";
}
$d = floor($seg / 86400);
$h = floor(($seg - ($d * 86400)) / 3600);
$m = floor(($seg - ($d * 86400) - ($h * 3600)) / 60);
$s = $seg % 60;
return "Dias: $d, horas: $h, minutos: $m, segundos: $s";
}
Suscribirse a:
Comentarios (Atom)