Skip to content

Instantly share code, notes, and snippets.

@grekodev
Created January 3, 2019 17:05
Show Gist options
  • Select an option

  • Save grekodev/02a8c2defe8e4cdf4bfb461a6287be51 to your computer and use it in GitHub Desktop.

Select an option

Save grekodev/02a8c2defe8e4cdf4bfb461a6287be51 to your computer and use it in GitHub Desktop.
Remover de un array un elemento objeto
var formas_pago = JSON.parse('<?php echo json_encode($forma_pagos); ?>');
function removeSelectPago(noclick) {
var seleindex;
$('.select_formapago').on('change', (e)=>{
var option_value = parseInt(e.target.value);
if (option_value !== 1 && noclick){
console.log(option_value)
seleindex = formas_pago.map(function(e) { return e.id; }).indexOf(option_value);
console.log(formas_pago);
formas_pago.splice(seleindex, 1);
}else if(option_value === 1 && noclick){
seleindex = formas_pago.map(function(e) { return e.id; }).indexOf(1);
formas_pago.splice(seleindex, 1);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment