How to prevent a second dialog box from appearing when I execute the alert or confirm function from javascript?

0

As the title says I want to know if there is any way to avoid duplicating the dialog box when using these functions, I am in the following dilemma: I want to show a confirmation message on a page where a payment is made and in the message the amount that was paid must be shown, in the framework that I use, a widget can be created, which among its attributes has one that allows to create a dialog box and this is not repeated as when the message is created from a JS script, the thing is that I can not make the amount sent by the input appear when the confirmation message is invoked from the widget, if someone can help I would appreciate it.

Widget code:

<?php 
$this->widget('bootstrap.widgets.TbButton', array('htmlOptions' => array('confirm' => '¿Está seguro que desea pagar y contabilizar el archivo?',)); 
?>

This is the code of the button with the attribute to print the direct message from the widget. this works for me but I do not know how to attach the value I sent from the input.

Code by JS:

function mensajeConfirmacion(){ 
    var monto_a_pagar = $(\'#'.CHtml::activeId($ComprobantePago,'monto_pagado').'\')‌​.val(); 
    var mensaje = confirm("¿Está seguro que desea pagar y contabilizar el archivo por Bs."+monto_a_pagar+"?"); 
    if (mensaje) { 
        activar_barra(); 
        return true; 
    }
    else { 
        return false; 
    } 
}

The problem with this is that the same alert is printed twice and the second alert overwrites the value obtained in the first one.

    
asked by Frank Guerra 27.06.2017 в 20:08
source

0 answers