How to check if the select did not find any rows

How to check if the select did not find any rows

GargiucnGargiucn Posts: 104Questions: 29Answers: 0

How can i check if the select did not find any rows so i can hide the field?

    pasEditor.dependent('passcons.pas_turno', function (val, data, callback) {
        if ( val ){ 
            // cerca nella tabella tris se esiste un nominativo che ha
            // tris.pas_turno = passcons.pass_turno e 
            // tris.tri_giorno = numero del giorno ricavato dalla data 
            pdata = pasEditor.val("passcons.pas_data");
            //alert(pdata+" - "+val);
            $.ajax({
                type: "POST",
                url: 'php/chk_giorno.php',
                async: true,
                data: {pdata: pdata, pturno: val}, 
                dataType: "json",
                success: function (data) {
                   if...   
                   ---> I would like to hide the field if the query found no rows <--
                   pasEditor.hide('passcons.pas_idtris');
                   else...
                   callback( data );
                },
                error: function (data) {
                    alert("Errore chk_giorno.php");
                },                      
            }); 
        }
        return {};      
    } );``

Thank for help...
Giuseppe

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    That code looks about right to me. I assume the test would be on the data parameter passed into the success() function - if it's empty or zero length or whatever your server-script returns with when empty, then the test is true.

    You would also want to add pasEditor.show('passcons.pas_idtris'); in the code if it isn't empty to ensure the field is shown.

    Colin

Sign In or Register to comment.