get right options with hooks
Posted: 2019-03-22 20:31
I'm working a hook using js files
it works, but it's only a concidence because I dont' have enough datas inside,
so at the moment the option1 is correctly what i need to check, but this can change with other datas
the problem is the value inside the option is not the foreign key as I thought (i made a test to see it), it seems is simply the list of the table in alphabetic order, the first element in this order
so, I pheraps need to check the label and go down and look the option associated the label if is checked, because the value inside the option is not connected directly any element of the foreign key
// INIZIALIZZA FUNZIONI
$j(function(){
// PREVIENE SALVATAGGIO SE CAMPO E' VUOTO - update
$j('#update').click(function(){
// VERIFICO
var verifica_radio_periferica = document.getElementById('tipologia_periferica1').checked;
var verifica_input_inchiostro = $j('#inchiostro_stampante').val();
// CASO STAMPANTE NON SELEZIONATA
if(verifica_input_inchiostro > 0 && verifica_radio_periferica !== true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante richiede la selezione di una stampante');
}
// CASO STAMPANTE SELEZIONATA SENZA INCHIOSTRO
if(verifica_input_inchiostro == '' && verifica_radio_periferica === true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante deve essere compilato per le stampanti');
}
}) // fine funzione update
// PREVIENE SALVATAGGIO SE CAMPO E' VUOTO - insert
$j('#insert').click(function(){
// VERIFICO
var verifica_radio_periferica = document.getElementById('tipologia_periferica1').checked;
var verifica_input_inchiostro = $j('#inchiostro_stampante').val();
// CASO STAMPANTE NON SELEZIONATA
if(verifica_input_inchiostro > 0 && verifica_radio_periferica !== true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante richiede la selezione di una stampante');
}
// CASO STAMPANTE SELEZIONATA SENZA INCHIOSTRO
if(verifica_input_inchiostro == '' && verifica_radio_periferica === true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante deve essere compilato per le stampanti');
}
}) // fine funzione update
}) // FINE FUNZIONE INIZIALIZZA
it works, but it's only a concidence because I dont' have enough datas inside,
so at the moment the option1 is correctly what i need to check, but this can change with other datas
the problem is the value inside the option is not the foreign key as I thought (i made a test to see it), it seems is simply the list of the table in alphabetic order, the first element in this order
so, I pheraps need to check the label and go down and look the option associated the label if is checked, because the value inside the option is not connected directly any element of the foreign key
// INIZIALIZZA FUNZIONI
$j(function(){
// PREVIENE SALVATAGGIO SE CAMPO E' VUOTO - update
$j('#update').click(function(){
// VERIFICO
var verifica_radio_periferica = document.getElementById('tipologia_periferica1').checked;
var verifica_input_inchiostro = $j('#inchiostro_stampante').val();
// CASO STAMPANTE NON SELEZIONATA
if(verifica_input_inchiostro > 0 && verifica_radio_periferica !== true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante richiede la selezione di una stampante');
}
// CASO STAMPANTE SELEZIONATA SENZA INCHIOSTRO
if(verifica_input_inchiostro == '' && verifica_radio_periferica === true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante deve essere compilato per le stampanti');
}
}) // fine funzione update
// PREVIENE SALVATAGGIO SE CAMPO E' VUOTO - insert
$j('#insert').click(function(){
// VERIFICO
var verifica_radio_periferica = document.getElementById('tipologia_periferica1').checked;
var verifica_input_inchiostro = $j('#inchiostro_stampante').val();
// CASO STAMPANTE NON SELEZIONATA
if(verifica_input_inchiostro > 0 && verifica_radio_periferica !== true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante richiede la selezione di una stampante');
}
// CASO STAMPANTE SELEZIONATA SENZA INCHIOSTRO
if(verifica_input_inchiostro == '' && verifica_radio_periferica === true){
return show_error('Inchiostro stampante', 'Il campo inchiostro stampante deve essere compilato per le stampanti');
}
}) // fine funzione update
}) // FINE FUNZIONE INIZIALIZZA