Forum Replies Created

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • in reply to: Error js messages #32886
    oivanr
    Participant

    Hi,
    This is the code that I am using to validate
    Line 4 prepare the var to display the message in lines 29 – 30
    Lines 15 – 30 call ajax, go to php function and return a value, depending on that I display the message. Works fine
    Line 6 – 8 include the code you gave me
    Line 31 I try to clear the message, but is not working
    The difference between this and the example you gave me is the ajax call
    Can you help me?

    1jQuery(function materiasAsignadas_Fecha($) { // formulario de tarea – busca si la sección materia ya 2)tiene prueba asignada ese día
    3) $(‘.quform-field-35_35’).change(function () {
    4 // para presentar / eliminar errores
    5 var form = $(‘.quform-form-35’).data(‘quform’);
    6 var $field = $(‘.quform-field-35_9’),
    7 materia = $(‘.quform-field-35_9’).val(),
    8 $element = $field.closest(‘.quform-element’);
    9
    10
    11 var accion = ‘materiaTareaFechaAsignada’;

    12 var fecha = $(‘.quform-field-35_35’).val();
    13 $(‘.quform-field-35_48’).val($(‘.quform-field-35_35’).val());
    14
    15 jQuery.ajax({
    16 type: ‘post’,
    17 url: ajax_var.url,
    18 datatype: ‘json’,
    19 data: {
    20 action: accion,
    21 security:ajax_var.nonce,
    22 materia:materia,
    23 fecha:fecha
    24 },
    25 success: function(salida){
    26 // lo que se recibe de PHP
    27 var original = salida.trim();
    28 if (original > 0){ // envío el mensaje de que ya existe
    29 form.addElementError(’35_9′, ‘Esta materia ya tiene tarea/prueba en esta
    30 fecha’).quformShowSlide();
    31 } else {$element.removeClass(‘quform-has-error’).find(‘.quform-error’).remove();}
    32 }
    33 });
    34 });
    35 });

    in reply to: Hide/show submit button #32867
    oivanr
    Participant

    Thanks,
    Sorry for the foolish question.

    in reply to: Print and export excel/word from html field #32851
    oivanr
    Participant

    HI,
    I make it work in this way
    1) Due to I make a query through ajax to php, I receive the data in a html format string
    2) The returned data include a div called “tabla_resultado”
    3) In the form I include an html file whith this code:

    <button class=”btn-default” type=”button” onclick=”printDiv(‘areaImprimir’);”>Imprimir</button>
    <button class=”btn-default” type=”button” onclick=”descargarExcel(‘areaImprimir’);”>Excel</button>
    <button class=”btn-default” type=”button” onclick=”descargarWord(‘areaImprimir’);”>Word</button>
    <button class=”btn-default” type=”button” onclick=”location.reload();”>Cambiar parámetros</button>

    <section id=”tabla_resultado” href=”#”></section>

    4) Finally I include this code in the js file
    function descargarWord(nombreDiv){ // <!– aqui exporto a Word!! –>
    var header = “<html xmlns:o=’urn:schemas-microsoft-com:office:office’ “+
    “xmlns:w=’urn:schemas-microsoft-com:office:word’ “+
    “xmlns=’http://www.w3.org/TR/REC-html40′>”+
    “<head><meta charset=’utf-8′><title>Export HTML to Word Document with JavaScript</title></head><body>”;
    var footer = “</body></html>”;
    var sourceHTML = header+document.getElementById(nombreDiv).innerHTML+footer;

    var source = ‘data:application/vnd.ms-word;charset=utf-8,’ + encodeURIComponent(sourceHTML);
    var fileDownload = document.createElement(“a”);
    document.body.appendChild(fileDownload);
    fileDownload.href = source;
    fileDownload.download = ‘descargaPilas.doc’;
    fileDownload.click();
    document.body.removeChild(fileDownload);
    }

    function descargarExcel(nombreDiv){ //– aqui exporto a Excel!!
    var uri = ‘data:application/vnd.ms-excel;base64,’
    , template = ‘<html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel” xmlns=”http://www.w3.org/TR/REC-html40″><meta http-equiv=”content-type” content=”application/vnd.ms-excel; charset=UTF-8″><head><!–[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]–></head><body><table>{table}</table></body></html>’
    , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
    , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }

    var table = ‘areaImprimir’;
    var nombre = ‘DescargaPilas.xls’;

    if (!table.nodeType) table = document.getElementById(table)
    //var ctx = { worksheet: name || ‘Worksheet’, table: table.innerHTML }
    var ctx = { worksheet: nombre || ‘Worksheet’, table: table.innerHTML }
    window.location.href = uri + base64(format(template, ctx))
    }

    // Aqui imprimo mediante javascript, uso la imagen de la impresora que está en el header
    function printDiv(nombreDiv) {
    var contenido= document.getElementById(nombreDiv).innerHTML;
    var contenidoOriginal= document.body.innerHTML;
    document.body.innerHTML = contenido;
    window.print();
    document.body.innerHTML = contenidoOriginal;
    }

    Hope this can be useful
    Regards,

    in reply to: Working with rows #32763
    oivanr
    Participant

    Thanks Ally,
    You are great.
    It works !!!

    in reply to: php call through ajax #31953
    oivanr
    Participant

    Hi,
    Thanks to your help i had I had done the call. Now I want to send a message if a field required is empty but through js. How I can send a message like the message quform type? or better, how I can access this message.
    Thanks again,

    in reply to: php call through ajax #31929
    oivanr
    Participant

    Thanks a lot for your quick response . I had try with your code, the issue is that when a call the “ajax_var.action” is due to I included that statement inside the plugin in the enqueue scripts action. I think is better to do this

    jQuery.ajax({
    type: ‘post’,
    url: the url of the plugin,
    data: ‘action= the name of the php hook or action’,
    success: function(result){
    $(‘#phpResult’).html(result);
    }
    Like you can see I delete de nonce because if I don’t use the enqueue action, I am not able to create a nonce inside the js code.

    I feel glad with your comments about this.
    Thanks again for your support.

    in reply to: aligning form #31862
    oivanr
    Participant

    Dear Ally,
    The problem was fixed. I am working in a localhost and for some reason the form looks diferent there. When I publish in my website the form is ok, aligned by the left. I am including an image.
    Thanks for your help.

    Attachments:
    You must be logged in to view attached files.
    in reply to: Carpet where forms are saved #31826
    oivanr
    Participant

    Thanks a lot. I will try.

    in reply to: Saving fields and default value #28670
    oivanr
    Participant

    Hi Ally,
    As usual it works perfectly.
    Thanks a lot,

    in reply to: Saving fields and default value #28659
    oivanr
    Participant

    Hi Ally,
    I am using the database area in the form configuration.
    1) The date is still saving 0000-00-00
    2) How I can get the name and the last name separately
    Thanks,

    in reply to: several custom javascript functions #28397
    oivanr
    Participant

    Dear Ally,
    You are right the function has a problem.
    I already find the problem, I did not include a single quote in the eleventh data value.
    Thanks for your help,

    in reply to: several custom javascript functions #28393
    oivanr
    Participant

    Send you the file here too

    Attachments:
    You must be logged in to view attached files.
    in reply to: several custom javascript functions #28392
    oivanr
    Participant

    I’ve already send you a mail the sender is oivanr.
    Thanks

    in reply to: Populate text field depending on dropdown selection #28348
    oivanr
    Participant

    It works fine.
    Thanks a lot

    in reply to: Verifying user email #28054
    oivanr
    Participant

    I am using this code in a plugin:
    add_filter(‘quform_post_validate_7’, function ($valor, $key, Quform_Form $form)
    {
    $args = array(
    ‘search’ => $form->getValueText(‘quform_7_3’),
    ‘search_columns’ => ‘user_email’
    );

    $user_query = new WP_User_Query( $args );

    if ( empty( $user_query->get_results() ) )
    {
    $valor = ‘Not found’;
    $form->setValueText(‘quform_7_4’)->$valor;
    }
    else
    {
    $usuario = $wp_user_query->get_results();
    $valor = $usuario->display_name;
    $form->setValueText(‘quform_7_4’)->$valor;
    }

    return $valor;
    }, 10, 2);

Viewing 15 posts - 1 through 15 (of 20 total)
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy