I'm working with the value of a variable in a JS file in a function in charged of updating values in a html table without the need of reloading the website as follows:
function updateTabla(plan, plan_valor, total_valor, descuento_nombre, descuento_valor, callback) {
if (descuento_nombre != 0) {
$(".txt-descuento").removeClass('sr-only');
$(".txt-descuento-nombre").html("Descuento: "+descuento_nombre);
$(".txt-descuento-valor").html("$ "+descuento_valor.toLocaleString()+" (COP)");
}
if ($("#codigo_actual").data('valor') != 0) {
total_valor = plan_valor - $("#codigo_actual").data('valor');
$(".txt-descuento").removeClass('sr-only');
$(".txt-descuento-nombre").html($("#codigo_actual").val());
$(".txt-descuento-valor").html($("#codigo_actual").data('valor'));
}
$(".txt-plan").html(plan);
$(".txt-valor").html("$ "+plan_valor.toLocaleString()+" (COP)");
$(".txt-total-valor").html("$ "+total_valor.toLocaleString()+" (COP)");
$("#amount").val(total_valor);
if(total_valor === 0){
var num = 'si ejecuta';
$("#frm-pago").removeAttr('url');
$("#frm-pago").attr({
url: www.prueba2.com;
});
}
console.log(total_valor);
console.log(num);
callback();
}
What I need is: using an If statement with "total_valor" make an action. The action I need is to modify a url in an html form inside of a php file. I am trying to modify the url attribute in the form like this:
$("#frm-pago").removeAttr('url');
$("#frm-pago").attr({
url: www.prueba2.com;
});
I need somebody's help that let me know what am I doing wrong or is there something else that I can try since the data in the JS is being well processed, when I check the values using console.log(total_valor) and console.log(num) I get the values that I want but can't change the html form.
I appreciate your help!
urlattribute … did you mean theactionperhaps? And btw., usingremoveAttris not necessary if you want to change the value, simply overwriting it will do.