Clear input type text when clicking the button

0

Hello, I need that when I click to send the data I delete what I write but without using a reset button this is my code of my button

THIS IS MY HTML AND JAVASCRIPT

<div class="col-sm-4 form-group">
  <label class="control-label">Digite cédula de Tecnicos Disponibles:</label>
  <input type="text" class="form-control" id="txt_tec_ins"></input>
  <input id="txt_tec_ins_id_tecnicos" type="hidden">
  <input id="txt_tec_ins_cedula" type="hidden">
  <input id="txt_tec_ins_nombre" type="hidden">
  <input id="txt_tec_ins_cargo" type="hidden">
  <input id="txt_tec_ins_v" type="hidden"><br>
  <input type="button" class="btn btn-success" value="Agregar técnico a inspección" id='btnagregartecins'>

$ ('# btnagregartecins'). on ('click', function (event) {         event.preventDefault ();

    tec_ins_id_tecnicos_1 = $('#txt_tec_ins_id_tecnicos').val();
    tec_ins_tecnicos_1_v = $('#txt_tec_ins_v').val();
    tec_ins_tecnicos_1 = $('#txt_tec_ins').val();

    //alert('Tecnicoid:' + tec_ins_id_tecnicos_1);

    if(tec_ins_id_tecnicos_1 == '' || tec_ins_tecnicos_1_v != tec_ins_tecnicos_1){
        alert('Debe seleccionar el técnico.');
        return;
    }


        var datosTecIns = {
            tec_ins_id_tecnicos         : $('#txt_tec_ins_id_tecnicos').val()
        };

        //alert('Tecnicoid:' + tec_ins_id_tecnicos_1);

        $.post('php/agregartecins.php', datosTecIns, function(data, textStatus, xhr) {
            if (data == 0){
                alert('No se pudo procesar. Intente mas tarde.');
                return;
            }
            if (data == 2){
                alert('No se ha ingresado el técnico a la inspeccion.');
                return;
            }
            if (data == 3){
                alert('No se pudo procesar. Error al insertar.');
                return;
            }
            if (data > 10){
                alert('Se ha guardado correctamente el registro: ' + data);
                $.post('php/cuadrilla_actualiza.php', datosTecIns, function(data2, textStatus, xhr) {
                    $('#datoscuadrilla').html(data2);
                });

                 optionstec = '';
                $.post('php/consultarCedulas.php', datosTecIns, function(data3, textStatus, xhr) {

                    optionstec = data3;
                    //alert(optionstec);
                });
                //alert("Procesando...");
                setTimeout ('Actualiza_select_tec()', 2000);




                return;
            }
            alert('Error:' + data);


        });


});

    
asked by JSACTM Music 27.09.2018 в 18:47
source

1 answer

1

You simply place at the end of the ajax when you succes like this:

$('#txt_tec_ins').val("");

by entering .val("") you are cleaning the value. Greetings

    
answered by 27.09.2018 / 19:01
source