0

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!

2
  • 2
    Form elements do not have a url attribute … did you mean the action perhaps? And btw., using removeAttr is not necessary if you want to change the value, simply overwriting it will do. Commented Jun 15, 2016 at 15:21
  • Thank you CBroe! That solved the problem. Commented Jun 15, 2016 at 17:25

2 Answers 2

1

Form elements do not have a url attribute - looks like you meant the action attribute instead.

And btw., using removeAttr is not necessary if you want to change the value, simply overwriting it will do.

Sign up to request clarification or add additional context in comments.

Comments

0

Try:

$("#frm-pago").attr("url", "www.prueba2.com");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.